Fix bug where i18next languageChanged event is fired prematurely
Summary
In profile modal language dropdown, its onChange handler fires i18next
's languageChanged
event. This means the event is fired when the user changes the value of that dropdown, before they submit the form. This also means that anything listening to the languageChanged
event will pick up the changes from the onChange.
Which version and OS are you using?
macOS, next branch from last week
How to reproduce the bug?
- Listen to
languageChanged
. Somewhere at the root component add this:
i18next.on('languageChanged', lang => console.log(`lang changed to ${lang}`))
- Open the profile settings modal.
- Change the value of the language field.
- Observe the console's
lang changed to ...
messages
What's the actual bug behavior?
languageChanged
event is fired before the user commits to the new language selection. This risks breaking any future listeners of languageChanged
as it is fired in an unintended manner.
What should happen instead?
Only call Don't call i18next.changeLanguage
on submit.i18next.changeLanguage
- it is already called in the set_settings
action downstream.
Logs and/or screenshots
Edited by Alex Tan