File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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+
127135def test_language_switcher_has_accessible_interaction_styles ():
128136 css = CSS_PATH .read_text (encoding = "utf-8" )
129137
You can’t perform that action at this time.
0 commit comments