gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Navigation Block: Focus trap behavior changes after submenu toggle

Open earthlingdavey opened this issue 8 months ago • 3 comments

Description

After toggling a navigation submenu open and closed using keyboard (Space/Enter), the Shift+Tab behavior changes unexpectedly. Focus trapping behaves differently before and after interaction, even though the submenu returns to its closed state.

Step-by-step reproduction instructions

  1. Navigate to a page with a Navigation block containing a submenu (dropdown)
  2. Set screen width to small width to activate mobile menu.
  3. Tab to the submenu toggle button
  4. Before interaction: Press Shift+Tab — focus moves naturally backward through the navigation items
  5. Press Space/Enter to open the submenu
  6. Press Space/Enter again to close the submenu (returns to aria-expanded="false")
  7. After interaction: Press Shift+Tab — focus now jumps unexpectedly to the tab item that's after the menu toggle button.

Screenshots, screen recording, code snippet

No response

Environment info

WP 6.9.0

Please confirm that you have searched existing issues in the repo.

  • [x] Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • [x] Yes

Please confirm which theme type you used for testing.

  • [x] Block
  • [ ] Classic
  • [ ] Hybrid (e.g. classic with theme.json)
  • [ ] Not sure

earthlingdavey avatar Mar 06 '26 11:03 earthlingdavey

Reproduction Report

Description

This report verifies whether the issue “Focus trap behavior changes after submenu toggle” can be reproduced.

Environment

  • WordPress: 6.9.4
  • PHP: 8.2.27
  • Server: nginx/1.26.1
  • Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.2.27)
  • Browser: Chrome 146.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 22.8.2
    • Test Reports 1.2.1

Steps Performed

  1. Opened a page containing a Navigation block with multiple items, including one with a submenu
  2. Switched to a small viewport width to trigger the mobile menu layout (also tested on desktop)
  3. Navigated using Tab until reaching:
    • the navigation menu toggle (mobile), or
    • the submenu toggle (desktop)
  4. Verified that before interaction, Shift + Tab correctly moved focus backward
  5. Opened and then closed:
    • the mobile navigation overlay, or
    • the submenu dropdown (desktop)
  6. Tested Shift + Tab again after interaction

Actual Results

  • ❌ The reported issue could not be reproduced
  • Focus behaviour remained consistent before and after submenu interaction
  • Shift + Tab continued to move focus backward as expected

Additional Notes

  • Hey @earthlingdavey, thanks for the report! I assume there may be a mismatch with the default Navigation block behavior, where in mobile view (e.g. with Twenty Twenty-Five), submenus are typically expanded within the overlay rather than using a separate toggle.
  • I tested in both mobile (overlay) and desktop (dropdown) contexts with various keyboard navigation patterns before and after interaction, but could not reproduce any unexpected focus behavior. Shift + Tab worked as expected in all cases.
  • It could be possible this is theme-specific or depends on a customized Navigation block implementation. If I may have missed any crucial step, could you please share a screen recording or more detailed steps along with the theme you’re using? I’ll be happy to test it again.

Supplemental Artifacts

Mobile Layout

https://github.com/user-attachments/assets/f8c5f4c7-8845-465e-9deb-c0a3a6c569c2

Desktop Layout

https://github.com/user-attachments/assets/603c1e34-c560-45a6-a6dd-4105ec96f9a0

BugReportOnWeb avatar Apr 01 '26 15:04 BugReportOnWeb

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] avatar May 02 '26 00:05 github-actions[bot]

Closing as non reproducible. Correct me if I'm wrong.

youknowriad avatar Jul 22 '26 10:07 youknowriad