Skip to content

Commit 03c2e5b

Browse files
committed
Add loader to engagement language switcher
1 parent 511c023 commit 03c2e5b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

web/src/components/engagement/shared/EngagementLanguageSwitcher.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { Suspense } from 'react';
2-
import { Box, MenuItem } from '@mui/material';
1+
import React, { Suspense, useState } from 'react';
2+
import { Box, CircularProgress, MenuItem } from '@mui/material';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { faChevronDown, faGlobe } from '@fortawesome/pro-regular-svg-icons';
55
import { Await } from 'react-router';
@@ -74,6 +74,7 @@ export const EngagementLanguageSwitcher = ({
7474
top = 0,
7575
onLanguageSelect,
7676
}: EngagementLanguageSwitcherProps) => {
77+
const [targetLanguageCode, setTargetLanguageCode] = useState(currentLanguageCode ?? defaultLanguage.code);
7778
if (!translationLanguages) {
7879
return null;
7980
}
@@ -158,7 +159,7 @@ export const EngagementLanguageSwitcher = ({
158159
if (item.code === activeLanguage.code) {
159160
return;
160161
}
161-
162+
setTargetLanguageCode(item.code);
162163
onLanguageSelect(item.code);
163164
}}
164165
sx={{
@@ -169,6 +170,9 @@ export const EngagementLanguageSwitcher = ({
169170
}}
170171
>
171172
{item.name}
173+
{item.code === targetLanguageCode && item.code !== activeLanguage.code && (
174+
<CircularProgress size={16} sx={{ marginLeft: 1 }} />
175+
)}
172176
</MenuItem>
173177
))}
174178
</DropdownMenu>

0 commit comments

Comments
 (0)