Skip to content

WS-2486-Fix keyboard navigation order of new nav component#14035

Open
Nabeel1276 wants to merge 9 commits into
latestfrom
WS-2486-fix-keyboard-navigation-order-of-new-nav-component
Open

WS-2486-Fix keyboard navigation order of new nav component#14035
Nabeel1276 wants to merge 9 commits into
latestfrom
WS-2486-fix-keyboard-navigation-order-of-new-nav-component

Conversation

@Nabeel1276
Copy link
Copy Markdown
Contributor

@Nabeel1276 Nabeel1276 commented May 19, 2026

Resolves JIRA: https://bbc.atlassian.net/browse/WS-2486

Summary

Fixes keyboard navigation so what the focus does not go onto the 2nd tier but instead, the focus closes the menu and moves to the first item on the page as required.

Code changes

Added new closeMenuWhenFocusLeaves function for closing menu when focus leaves
Added unit test for the function

Testing

  1. Navigate to a local BBC page that contains the new nav component - E.g http://localhost:7081/portuguese/articles/clyp0wdzgjlo?renderer_env=live.
  2. Open dev tools and inspect on mobile
  3. Tab through until focus leaves the nav
  4. Nav should close upon focus leaving and focus should be on next item

Useful Links

Copilot AI review requested due to automatic review settings May 19, 2026 10:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes keyboard navigation order in the new canonical navigation component by closing the dropdown menu when keyboard focus moves outside of its container.

Changes:

  • Adds an onBlur handler on the wrapper div around the top row and dropdown.
  • Uses currentTarget.contains(relatedTarget) to detect focus leaving the menu subtree and closes the menu when it does.

@Nabeel1276 Nabeel1276 self-assigned this May 19, 2026
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.

2 participants