diff --git a/app/src/organisms/Desktop/SystemLanguagePreferenceModal/__tests__/SystemLanguagePreferenceModal.test.tsx b/app/src/organisms/Desktop/SystemLanguagePreferenceModal/__tests__/SystemLanguagePreferenceModal.test.tsx index a91d7389072..8ed93c1cb81 100644 --- a/app/src/organisms/Desktop/SystemLanguagePreferenceModal/__tests__/SystemLanguagePreferenceModal.test.tsx +++ b/app/src/organisms/Desktop/SystemLanguagePreferenceModal/__tests__/SystemLanguagePreferenceModal.test.tsx @@ -180,4 +180,16 @@ describe('SystemLanguagePreferenceModal', () => { 'zh-Hant' ) }) + + it('should not open update modal when system language changes to an unsuppported language', () => { + vi.mocked(getSystemLanguage).mockReturnValue('es-MX') + render() + + expect(screen.queryByRole('button', { name: 'Don’t change' })).toBeNull() + expect( + screen.queryByRole('button', { + name: 'Use system language', + }) + ).toBeNull() + }) }) diff --git a/app/src/organisms/Desktop/SystemLanguagePreferenceModal/index.tsx b/app/src/organisms/Desktop/SystemLanguagePreferenceModal/index.tsx index 5bfc91e849e..b4bf54c0d17 100644 --- a/app/src/organisms/Desktop/SystemLanguagePreferenceModal/index.tsx +++ b/app/src/organisms/Desktop/SystemLanguagePreferenceModal/index.tsx @@ -46,14 +46,7 @@ export function SystemLanguagePreferenceModal(): JSX.Element | null { const storedSystemLanguage = useSelector(getStoredSystemLanguage) const showBootModal = appLanguage == null && systemLanguage != null - - // only show update modal if we support the language their system has updated to - const showUpdateModal = - appLanguage != null && - systemLanguage != null && - LANGUAGES.find(language => language.value === systemLanguage) != null && - storedSystemLanguage != null && - systemLanguage !== storedSystemLanguage + const [showUpdateModal, setShowUpdateModal] = useState(false) const title = showUpdateModal ? t('system_language_preferences_update') @@ -123,6 +116,13 @@ export function SystemLanguagePreferenceModal(): JSX.Element | null { void i18n.changeLanguage(systemLanguage) } } + // only show update modal if we support the language their system has updated to + setShowUpdateModal( + appLanguage != null && + matchedSystemLanguageOption != null && + storedSystemLanguage != null && + systemLanguage !== storedSystemLanguage + ) } }, [i18n, systemLanguage, showBootModal])