Reworking a Shopify mega menu for keyboard and VoiceOver

Desktop dropdowns and a mobile menu drawer served the same navigation. They needed different keyboard and screen reader behavior because one opened within the page and the other covered it.

Hand on a keyboard beneath a monitor showing an open navigation menu with a focus outline

Identify what the navigation actually does

The desktop header used a mega menu for groups of ordinary storefront links. Its markup presented those groups as an application-style menubar using menubar, menu, and menuitem roles. Those roles carry keyboard expectations such as using arrow keys to move within the menu. A shopper looking for a category can work with buttons that expand link groups and links that behave like the rest of the site.

I switched the desktop header to disclosure navigation. The W3C’s reference example uses normal navigation semantics for grouped website links and describes how buttons expose expanded state. It also calls for testing the result with browsers and assistive technology, which matters when part of the same navigation is presented differently on mobile. W3C disclosure navigation example

Keep visible links in the normal Tab order

The desktop markup became a navigation landmark with native buttons controlling panels of links. Each disclosure button identifies its panel with aria-controls and reports its current state with aria-expanded. Opening a panel lets a shopper Tab through its visible links in order. Arrow Down is a shortcut to the first visible link, and Escape closes the dropdown and puts focus back on the button that opened it.

The interaction also accounts for mouse and keyboard use on the same page. A pointer leaving the menu should not close it while focus is still on a link inside. Keeping the menu open in that situation lets the shopper resume their current keyboard interaction without losing their place.

Give the open mobile drawer a clear boundary

The VoiceOver follow-up addressed the mobile drawer. It covers the page when open, so its active state uses named dialog semantics. The implementation exposed the drawer as a modal, gave it an accessible name, and changed the menu toggle’s label to describe closing the menu. It also marked selected background branches inert and hid those branches from assistive technology while the drawer was open.

The cleanup saved attributes it changed so it could restore previous values when the drawer closed. That state also needed to be reconciled when crossing the desktop breakpoint, where the navigation is no longer a modal drawer. Escape handling distinguishes the active layer, such as a search view or nested group, so focus can return to the corresponding control. When checking the cleanup, account for background content that was already marked inert or hidden before the menu opened. Restoring the page means restoring the previous values that belong to other parts of the theme. The W3C dialog pattern explains the expected focus and background behavior for modal overlays. W3C modal dialog pattern

Checks to run with a keyboard and VoiceOver

Test the desktop header and mobile drawer independently with the same links. These are suggested checks for a similar navigation change.

  • Desktop Tab order. Enter the header with Tab, open a dropdown from its button, and check that Tab and Shift+Tab follow the visible links in a predictable order.
  • Desktop Escape. Close the dropdown from a focused link and from the trigger itself. Confirm the button regains focus and announces the collapsed state.
  • Mobile drawer. Open it with VoiceOver, listen for the drawer name, and navigate the open drawer to check that background content stays out of the way.
  • Nested layers. Open a submenu or search in the drawer, close that layer, then close the drawer. Check focus after both actions.
  • Breakpoint transition. Resize or rotate with the drawer open. After switching to desktop, check that the header and page content can be reached again.

Inspect the trigger, panel, and close path together

Review a navigation state by checking which control is focused, whether its expanded state agrees with the visual panel, and which links the keyboard and screen reader can reach. Once a drawer closes, check who owns focus and whether any attributes that disabled background content have been restored.

For a useful QA report, record the viewport, input method, control you started from, and element that held focus after closing. A recording of the visual dropdown helps explain the layout, and the focus sequence or screen reader announcement captures what the shopper actually encountered. With those details, the developer can investigate the desktop disclosure or the mobile drawer directly.

Is your storefront navigation hard to use?

Share the page, device, and steps that reproduce the issue. A short description of where focus goes is enough to start.