Skip to content

A11y Bug 6210624: Keyboard focus and arrow key navigation in location dropdown#653

Merged
aanchalbhansali merged 6 commits intouser/kpeddireddy/LocationButtonTabfrom
copilot/fix-location-dropdown-keyboard-focus
Apr 1, 2026
Merged

A11y Bug 6210624: Keyboard focus and arrow key navigation in location dropdown#653
aanchalbhansali merged 6 commits intouser/kpeddireddy/LocationButtonTabfrom
copilot/fix-location-dropdown-keyboard-focus

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

When the location dropdown is expanded via keyboard, focus remains on the trigger button instead of moving to the currently selected section item. Additionally, the OneNotePicker library only handles Enter/Tab key events — there is no Up/Down arrow key navigation in the popup list, leaving keyboard users unable to navigate between sections or notebooks using arrow keys.

Changes

  • sectionPicker.tsxonPopupToggle: When the popup opens, schedules a setTimeout(0) callback (to allow DOM render) that:
    1. Focuses the currently selected section element by curSectionId. Falls back to the first keyboard-navigable item in #sectionPickerContainer if no selected element is found.
    2. Attaches a keydown listener on #sectionPickerContainer for Up/Down arrow key navigation. The listener finds all visible keyboard-navigable items in the popup and moves focus to the previous (Up) or next (Down) item relative to the currently focused element. A data-arrow-key-handler-attached attribute guards against duplicate listeners.

Demo:
https://github.com/user-attachments/assets/b66fb057-5e67-42ab-a743-22cd4286a7f5

Copilot AI changed the title [WIP] Fix keyboard focus issue in location dropdown Fix: Keyboard focus does not land on selected item when opening location dropdown Mar 31, 2026
Copilot AI requested a review from KethanaReddy7 March 31, 2026 10:09
@KethanaReddy7
Copy link
Copy Markdown

@copilot the keyboard focus is falling inside its only working with Tab keys and not Arrow keys. Can you please fix this

Agent-Logs-Url: https://github.com/OneNoteDev/WebClipper/sessions/029fac6a-7d39-4214-b537-4cab9afd25e1

Co-authored-by: KethanaReddy7 <257986085+KethanaReddy7@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot the keyboard focus is falling inside its only working with Tab keys and not Arrow keys. Can you please fix this

Fixed in commit 20594c7. The OneNotePicker library only handles Enter/Tab key events — there was no arrow key navigation at all in the popup list. I've added a keydown listener on the popup container (#sectionPickerContainer) that intercepts Up/Down arrow keys and moves focus between the keyboard-navigable items. A guard attribute (data-arrow-key-handler-attached) prevents duplicate listeners if the popup is reopened.

Copilot AI changed the title Fix: Keyboard focus does not land on selected item when opening location dropdown Fix: Keyboard focus and arrow key navigation in location dropdown Apr 1, 2026
@KethanaReddy7
Copy link
Copy Markdown

@copilot I'm able to navigate through sections using up and down arrow key but navigation through notebooks using up and down arrow keys is not working. I am able to navigate through the notebooks if i only open the prev notebook sections. Can you fix this

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 1, 2026

@copilot I'm able to navigate through sections using up and down arrow key but navigation through notebooks using up and down arrow keys is not working. I am able to navigate through the notebooks if ...

Fixed in commit 155b3d7. The root cause was that the OneNotePicker library uses a "Closed" CSS class to visually hide children of collapsed notebooks, but those child <li> elements (sections/sectionGroups) stay in the DOM with their tabindex attributes. The arrow key handler was treating them as navigable, so pressing Down on a collapsed notebook jumped to a hidden section instead of the next notebook.

The fix filters focusable items to only visible ones — specifically, items whose parentElement does not have a .Closed ancestor. This keeps the collapsed notebook header itself focusable (it has the Closed class directly on itself, not on an ancestor) while excluding its hidden children.

@KethanaReddy7 KethanaReddy7 marked this pull request as ready for review April 1, 2026 08:52
@KethanaReddy7 KethanaReddy7 changed the base branch from master to user/kpeddireddy/LocationButtonTab April 1, 2026 08:55
@KethanaReddy7 KethanaReddy7 changed the title Fix: Keyboard focus and arrow key navigation in location dropdown A11y Bug 6210624: Keyboard focus and arrow key navigation in location dropdown Apr 1, 2026
Copy link
Copy Markdown
Contributor

@aanchalbhansali aanchalbhansali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@aanchalbhansali aanchalbhansali merged commit fb7808e into user/kpeddireddy/LocationButtonTab Apr 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants