mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-08 17:12:25 +05:30
Close language switcher popup not earlier than locale will be loaded and applied
This commit is contained in:
parent
88c2eab802
commit
7a7d07203e
@ -17,9 +17,11 @@ const LanguageSwitcher: ComponentType<Props> = ({ onClose = () => {} }) => {
|
||||
|
||||
const onChangeLang = useCallback(
|
||||
(lang: string) => {
|
||||
dispatch(changeLang(lang));
|
||||
// TODO: await language change and close popup, but not earlier than after 300ms
|
||||
setTimeout(onClose, 300);
|
||||
Promise.all([
|
||||
// 300ms is necessary for the visual animation of the language change to be completed
|
||||
new Promise((resolve) => setTimeout(resolve, 300)),
|
||||
dispatch(changeLang(lang)),
|
||||
]).then(onClose);
|
||||
},
|
||||
[dispatch, onClose],
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user