@@ -67,9 +67,7 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
6767 }
6868 this . props . onPopupToggle ( shouldNowBeOpen ) ;
6969 if ( shouldNowBeOpen ) {
70- // After the popup renders, move keyboard focus to the currently selected section item
71- // so that keyboard users can identify which item is selected and navigate from there.
72- // Also attach an arrow key handler so keyboard users can navigate the list with Up/Down.
70+ // Focus the selected section and attach arrow key navigation for keyboard users
7371 setTimeout ( ( ) => {
7472 let sectionPickerPopup = document . getElementById ( "sectionPickerContainer" ) ;
7573
@@ -86,21 +84,14 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
8684 elementToFocus . focus ( ) ;
8785 }
8886
89- // Attach Up/Down arrow key navigation for the popup list.
90- // The OneNotePicker library only handles Enter/Tab, so we add arrow key support here.
91- // The listener is attached to the popup element which is removed from the DOM when the
92- // popup closes, so there is no need to explicitly clean it up.
93- // Guard against attaching multiple listeners if onPopupToggle(true) is called more than once.
94- // Use capture so the popup still receives Up/Down events before child controls suppress bubbling.
87+ // Attach Up/Down arrow key navigation (OneNotePicker only handles Enter/Tab)
9588 if ( sectionPickerPopup && ! sectionPickerPopup . getAttribute ( "data-arrow-key-handler-attached" ) ) {
9689 sectionPickerPopup . setAttribute ( "data-arrow-key-handler-attached" , "true" ) ;
9790 sectionPickerPopup . addEventListener ( "keydown" , ( e : KeyboardEvent ) => {
9891 if ( e . which !== Constants . KeyCodes . up && e . which !== Constants . KeyCodes . down ) {
9992 return ;
10093 }
10194 e . preventDefault ( ) ;
102- // Only include visible items — exclude elements whose parent is inside a "Closed"
103- // collapsed notebook or sectionGroup (children remain in the DOM but are hidden via CSS).
10495 let focusableItems = Array . prototype . slice . call (
10596 sectionPickerPopup . querySelectorAll ( "[tabindex]:not([tabindex=\"-1\"])" )
10697 ) . filter ( ( el ) => {
@@ -302,7 +293,6 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
302293 }
303294
304295 // Attach escape key handler to return focus to the dropdown button when Escape is pressed
305- // This is needed because the OneNotePicker component handles Escape internally without calling onPopupToggle
306296 attachEscapeFocusHandler ( element : HTMLElement , isInitialized : boolean ) {
307297 if ( ! isInitialized ) {
308298 const escKeyCode = 27 ;
0 commit comments