Added exposition on isoCode management

This commit is contained in:
Marc Brooks 2025-08-21 16:37:46 +00:00
parent c28f3b4cd0
commit ce95be8af9
1 changed files with 6 additions and 1 deletions

View File

@ -7,6 +7,12 @@ export function useKeyboardLayout(): { keyboard: KeyboardLayout } {
const { keyboardLayout } = useSettingsStore();
const isoCode = useMemo(() => {
// If we don't have a specific layout, default to "en-US" because that was the original layout
// developed so it is a good fallback. Additionally, we replace "en_US" with "en-US" because
// the original server-side code used "en_US" as the default value, but that's not the correct
// ISO code for English/United State. To ensure we remain backward compatible with devices that
// have not had their Keyboard Layout selected by the user, we want to treat "en_US" as if it was
// "en-US" to match the ISO standard codes now used in the keyboardLayouts.
console.log("Current keyboard layout from store:", keyboardLayout);
if (keyboardLayout && keyboardLayout.length > 0)
return keyboardLayout.replace("en_US", "en-US");
@ -14,7 +20,6 @@ export function useKeyboardLayout(): { keyboard: KeyboardLayout } {
}, [keyboardLayout]);
const keyboard = useMemo(() => {
console.log("Selected keyboard layout:", isoCode);
return selectedKeyboard(isoCode);
}, [isoCode]);