Skip to content

Commit 9424f43

Browse files
committed
fix: recover language menu focus
1 parent 46f6d0b commit 9424f43

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

atlas/js/app.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,12 @@ function moveLanguageFocus(direction) {
824824
const items = languageMenuItems();
825825
if (!items.length) return;
826826

827-
const currentIndex = Math.max(0, items.indexOf(document.activeElement));
827+
const currentIndex = items.indexOf(document.activeElement);
828+
if (currentIndex === -1) {
829+
activeLanguageItem()?.focus();
830+
return;
831+
}
832+
828833
const nextIndex = (currentIndex + direction + items.length) % items.length;
829834
items[nextIndex].focus();
830835
}

tests/test_atlas_static.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ def test_app_localizes_accessibility_landmarks():
124124
assert 'ui.audioControls.setAttribute("aria-label", text.audioControls);' in script
125125

126126

127+
def test_language_menu_focus_recovers_from_trigger_reentry():
128+
script = JS_PATH.read_text(encoding="utf-8")
129+
130+
assert "const currentIndex = items.indexOf(document.activeElement);" in script
131+
assert "if (currentIndex === -1)" in script
132+
assert "activeLanguageItem()?.focus();" in script
133+
134+
127135
def test_language_switcher_has_accessible_interaction_styles():
128136
css = CSS_PATH.read_text(encoding="utf-8")
129137

0 commit comments

Comments
 (0)