Skip to content

Commit dd6f09e

Browse files
committed
Navigate using up and down arrow keys
1 parent 155b3d7 commit dd6f09e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/scripts/clipperUI/components/sectionPicker.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
8181
// The listener is attached to the popup element which is removed from the DOM when the
8282
// popup closes, so there is no need to explicitly clean it up.
8383
// Guard against attaching multiple listeners if onPopupToggle(true) is called more than once.
84+
// Use capture so the popup still receives Up/Down events before child controls suppress bubbling.
8485
if (sectionPickerPopup && !sectionPickerPopup.getAttribute("data-arrow-key-handler-attached")) {
8586
sectionPickerPopup.setAttribute("data-arrow-key-handler-attached", "true");
8687
sectionPickerPopup.addEventListener("keydown", (e: KeyboardEvent) => {
@@ -90,7 +91,7 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
9091
e.preventDefault();
9192
// Only include visible items — exclude elements whose parent is inside a "Closed"
9293
// collapsed notebook or sectionGroup (children remain in the DOM but are hidden via CSS).
93-
let focusableItems = Array.from(
94+
let focusableItems = Array.prototype.slice.call(
9495
sectionPickerPopup.querySelectorAll("[tabindex]:not([tabindex=\"-1\"])")
9596
).filter((el) => {
9697
let parent = (el as HTMLElement).parentElement;
@@ -107,7 +108,7 @@ export class SectionPickerClass extends ComponentBase<SectionPickerState, Sectio
107108
let nextIndex = currentIndex >= focusableItems.length - 1 ? focusableItems.length - 1 : currentIndex + 1;
108109
focusableItems[nextIndex].focus();
109110
}
110-
});
111+
}, true);
111112
}
112113
}, 0);
113114
}

0 commit comments

Comments
 (0)