Skip to content

Fix Menu: restore focus to trigger on ArrowLeft/ArrowRight boundary - #9

Merged
stierpm merged 1 commit into
mainfrom
fix/menu-arrow-key-boundary-focus
Apr 14, 2026
Merged

stierpm merged 1 commit into
mainfrom
fix/menu-arrow-key-boundary-focus

Conversation

@stierpm

@stierpm stierpm commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #10

When a user navigates into a dropdown with the keyboard and presses ArrowLeft from the first top-level item's dropdown, or ArrowRight from the last, focus is silently dropped. The optional chaining (?.focus()) produced a no-op when no adjacent sibling existed, leaving the user with no focused element.

This two-line fix replaces the optional chain with a nullish-coalescing fallback to parentItem, so focus always returns to the trigger that owns the dropdown — matching the Escape key behavior and WCAG 2.1 expectations.

Files changed: src/components/Menu.js (2 lines)

When a user navigates into a dropdown with the keyboard and presses ArrowLeft
from the first top-level item's dropdown, or ArrowRight from the last, focus
was silently dropped. The optional chaining (?.focus()) produced a no-op when
no adjacent sibling existed, leaving the user with no focused element.

Replace the optional chain with a nullish-coalescing fallback to parentItem,
so focus always returns to the trigger that owns the dropdown — matching the
Escape key behavior and WCAG 2.1 expectations.

Files changed: src/components/Menu.js (2 lines)
@stierpm
stierpm merged commit b58046b into main Apr 14, 2026
@stierpm
stierpm deleted the fix/menu-arrow-key-boundary-focus branch April 14, 2026 15:16
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.

Bug: Menu arrow key boundary focus is silently lost

1 participant