Test keyboard focus when a mobile navigation menu opens
A mobile menu may open perfectly by touch yet lose a visitor using a keyboard. Focus can jump behind the panel, enter links that look closed, disappear when the menu closes, or get trapped with no exit. Test the published narrow-screen version as a sequence of states, not just a button that visually opens. The worksheet below gives a reproducible route for an editor, designer, or developer to share.
Boletolibre editorial team
Published
Use the focus-state test card
Download the mobile-menu focus test card (Markdown, English)
Choose one public page with the actual header used by visitors. Write down the viewport width, browser, operating system, and whether you used a physical keyboard or a browser's responsive view. Start with an ordinary visitor task such as finding the event schedule from the menu and then returning to the page. Record each keyboard action and the element that visibly receives focus; a screenshot alone cannot show where focus went after a key press.
The card has separate rows for closed, newly opened, link traversal, nested content, closing, and resizing. Use it to describe the first failing transition, not merely ‘menu inaccessible.’ A CMS editor may be able to correct labels or link order, while the component owner will need to repair focus management or hidden links. The card is a QA aid, not an accessibility certificate.
First identify what kind of panel opens
Many website navigation panels are disclosures: a button shows or hides a group of ordinary links. In the W3C disclosure pattern, Enter or Space activates the button and its expanded state reflects whether the content is visible. The W3C navigation example keeps Tab and Shift+Tab for movement through visible links; arrow-key shortcuts are optional additions, not a replacement for ordinary link tabbing. Do not demand application-style menu-bar keys just because the design calls itself a ‘menu.’[1][2]
A full-screen panel may instead behave as a modal dialog. If it is truly modal, focus moves inside when it opens, Tab stays within it, Escape closes it, and focus usually returns to the opener. A simple non-modal disclosure should not silently trap focus as if it were a dialog. Ask the template or component owner which interaction is intended; then test that interaction consistently. W3C's modal pattern is a model for modal behavior, not an instruction to turn every mobile menu into a dialog.[3]
Check the closed state before opening
At the narrow width, begin at the top of the page and use Tab until the menu trigger is focused. You should be able to identify it without pointing at it; the focus indicator must remain visible. If it is an icon-only control, its accessible name should identify its action, and the visible design should not make the control indistinguishable from decoration. Press Enter and Space in separate passes to confirm that each activates a button-style disclosure. Do not add positive `tabindex` values simply to force a visual order; a logical source order is the stronger fix.[5][1][4][7][8]
Before opening, keep tabbing. Links inside a visually closed panel should not appear as invisible keyboard stops. If Tab seems to vanish into the header, record the focused element and whether the panel is actually hidden or merely moved off-screen. That is a component problem, even if a mouse user sees nothing wrong. If the site's menu is always visible at a wider breakpoint, repeat the closed-state check after reducing the viewport again; responsive transitions can leave stale focus targets.
Follow focus through the open panel
Open the panel from the keyboard and pause. In a disclosure, focus can remain on the trigger; the next Tab should reach the next visible control in a logical sequence; if the links immediately follow the trigger, that will be the first link. In a modal, focus should move to a meaningful element inside. In either design, a sighted keyboard user must be able to see the current focus, and the reading sequence must make sense. W3C's Focus Order guidance permits more than one valid sequence, but it must preserve meaning and operation.[2][3][4][5]
Use Tab and Shift+Tab all the way through the links. Test a nested section if the menu has one: activate its button, visit its newly visible links, then collapse it. W3C's disclosure example uses a button with `aria-expanded` to communicate the shown or hidden state; checking this state in the rendered accessibility tree can help a developer diagnose a mismatch. From the content editor's perspective, also check whether link names are clear and whether a critical route is buried after dozens of links.[2]
If focus moves behind an open full-screen panel, the visitor may act on invisible page controls. If focus never leaves a non-modal disclosure, the visitor may be unable to reach the rest of the page. A true modal intentionally contains focus, but it must be dismissible. Record the precise keystroke and visible result; ‘focus trap’ is only a useful report when the expected exit behavior is stated.[3][6]
Close the panel and find focus again
Close with the visible close control or the same trigger, then try Escape. The W3C disclosure navigation example closes an open dropdown on Escape and returns focus to the controlling button. Its specific implementation is illustrative; test what your actual panel promises. For a modal, Escape and a close control should end the dialog and usually return focus to its opener. If the opener has disappeared after a page change, the developer should choose another logical destination. Focus must never be left on a hidden link or lost to an unexpected start of page.[2][3]
After closing, press Tab once more. The next stop should be understandable in relation to the header and page, not jump to a hidden child link or restart at the browser chrome. Reopen and close in the reverse direction with Shift+Tab as well. A menu that works once may fail after a nested section was opened, after a route was followed, or after a responsive resize. Record those state combinations rather than assuming one pass covers them.[4]
Use a transition matrix to pinpoint the defect
| State and action | Expected observation | Common failure to record |
|---|---|---|
| Closed → Tab to trigger | Visible focus on a named control | Trigger skipped or focus invisible |
| Closed → Enter or Space | Panel opens and state updates | Only touch/click works |
| Open → Tab forward/back | Visible links follow a logical order | Focus reaches hidden or covered content |
| Nested section → expand/collapse | New links become reachable, then leave sequence | Closed links remain focusable |
| Open → close control (Escape if supported) | Panel closes; focus has a logical location | Focus remains hidden or jumps unexpectedly |
| Open → resize/change orientation | Current focus remains findable | Focus disappears at breakpoint |
The matrix describes observations, not a universal keystroke recipe for every custom widget. If the site uses an actual modal, apply the dialog expectations in the previous sections. If it uses a disclosure, use ordinary link tabbing. An automated scan may flag missing attributes, but only a real keyboard pass shows whether the visitor can enter, use, and leave the menu.
Hand off the smallest reproducible failure and retest
For each failure, send the component owner the public URL, viewport width, browser and device, whether the panel is a disclosure or modal, starting focus, exact keys, expected destination, observed destination, and a short recording if available. Include the affected route: ‘I cannot reach the schedule link after opening the menu’ is clearer than ‘keyboard broken.’ The editor can verify link text and order; the developer can inspect button semantics, hidden-state handling, focus placement, and close behavior.
After a fix, repeat the complete sequence at narrow and wide widths. Check the published site with keyboard alone; when possible, try a physical keyboard on a phone or tablet because responsive emulation does not duplicate every real-device interaction. WebAIM specifically recommends mobile keyboard testing. A passed menu sequence does not replace the site's broader accessibility review of page content, forms, contrast, and screen-reader behavior.[8]
Sources and further reading
- Disclosure (Show/Hide) PatternW3C Web Accessibility Initiative, ARIA Authoring Practices Guide · Accessed
- Dialog (Modal) PatternW3C Web Accessibility Initiative, ARIA Authoring Practices Guide · Accessed
- Understanding SC 2.4.3: Focus OrderW3C Web Accessibility Initiative · Accessed
- Understanding SC 2.4.7: Focus VisibleW3C Web Accessibility Initiative · Accessed
- Understanding SC 2.1.2: No Keyboard TrapW3C Web Accessibility Initiative · Accessed
- Understanding SC 4.1.2: Name, Role, ValueW3C Web Accessibility Initiative · Accessed
- Keyboard AccessibilityWebAIM, Utah State University · Accessed