Skip to content

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

Merged
alex-magana merged 32 commits into
latestfrom
WS-2486-fix-keyboard-navigation-order-of-new-nav-component
Jun 3, 2026
Merged

WS-2486-Fix keyboard navigation order of new nav component#14035
alex-magana merged 32 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 blur event listener function for closing menu when tabbing after last element in drop down menu.
  • Added unit test for the function
  • Updated testHelpers to include real links so the test accurately reflects how the dropdown menu works in practice.

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
shiftKey,
currentTarget,
}: KeyboardEvent) => {
if (key !== 'Tab' || shiftKey) return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't understand this one. Can you explain?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Realised it wasn't needed, it's been removed.

@pvaliani pvaliani self-requested a review May 26, 2026 15:29
@alex-magana alex-magana requested a review from eagerterrier June 2, 2026 10:53
…ent' of github.com:bbc/simorgh into WS-2486-fix-keyboard-navigation-order-of-new-nav-component
@alex-magana alex-magana merged commit 8fb13d4 into latest Jun 3, 2026
13 checks passed
@alex-magana alex-magana deleted the WS-2486-fix-keyboard-navigation-order-of-new-nav-component branch June 3, 2026 13:29
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.

7 participants