From fd5e4d3747c7e57dceb0fc25ff5b36d3fbe15ca0 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Tue, 11 Aug 2026 19:15:32 -0500 Subject: [PATCH] docs: refine mobile header focus behavior --- .../specs/2026-08-11-mobile-header-design.md | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/superpowers/specs/2026-08-11-mobile-header-design.md b/docs/superpowers/specs/2026-08-11-mobile-header-design.md index 70b51de..25abd76 100644 --- a/docs/superpowers/specs/2026-08-11-mobile-header-design.md +++ b/docs/superpowers/specs/2026-08-11-mobile-header-design.md @@ -34,8 +34,9 @@ row and returns focus to the search button. The theme button opens an anchored popover below the bar. The popover contains Light, Dark, and System as one radio group. It keeps the existing preference order: an explicit user choice wins; System follows the operating-system -preference. Escape or a click outside closes the popover and returns focus to -the theme button. +preference. Escape or the theme button closes the popover and restores focus to +the theme button. A pointer or focus move outside closes the popover without +overriding the user's new focus. ### Menu @@ -43,9 +44,15 @@ The menu button opens the primary navigation below the bar. The existing links and URLs stay unchanged. Escape closes the menu and returns focus to the menu button. -Opening Search, Theme, or Menu closes either of the other two panels. Resizing -to desktop closes mobile panels and prevents focus from remaining in hidden -content. The header does not trap Tab focus. +Opening Search, Theme, or Menu closes either of the other two panels. The newly +activated control owns focus; closing another panel does not restore its old +focus. Search moves focus to its input. Theme and Menu keep focus on their +buttons, so the next Tab enters the checked radio or first navigation link. + +Resizing to desktop closes mobile-only panel state. If that closure would hide +the focused element, focus moves to its visible trigger. If the Menu trigger +itself becomes hidden, focus moves to the first primary-navigation link. Focus +otherwise stays unchanged. The header does not trap Tab focus. ## Progressive enhancement @@ -60,7 +67,8 @@ additional rows, but it must remain readable and operable. - Toggle buttons expose `aria-expanded` and `aria-controls`. - The theme choices keep native radio semantics and a fieldset legend. - Popover and panel state never hide the active element. -- Escape and resize restore or move focus predictably. +- Escape restores trigger focus; outside clicks preserve the new target. +- Resize uses the explicit focus destinations defined above. - Keyboard order is Search, Theme, Menu, followed by the opened panel. - Focus indicators meet the existing CHRNX contrast and visibility rules. - Reduced-motion mode removes nonessential transitions. @@ -68,21 +76,27 @@ additional rows, but it must remain readable and operable. ## Responsive scope The compact bar applies at the existing mobile breakpoint, up to 599 px. Tablet -and desktop behavior remain unchanged unless testing exposes a breakpoint -collision. +and desktop behavior remain unchanged. Any breakpoint collision must be solved +inside the mobile scope or returned for approval. ## Testing Write failing tests before production changes. Cover: -- one-row layout at 375 px; +- one-row layout at the narrowest supported width, 375 px, and 599 px; +- no overlap or overflow at 375 px and the 599/600 px boundary; +- unchanged non-mobile layout at 600 px and representative desktop widths; - mutual exclusion of Search, Theme, and Menu; - Escape, outside click, and focus restoration; - Tab order without a focus trap; - mobile-to-desktop and desktop-to-mobile resize behavior; - no-JavaScript navigation and search; -- Light, Dark, and System persistence; +- stored Light or Dark overriding the operating-system preference and later + operating-system changes; +- System following operating-system changes; +- theme preference surviving reloads; - 44–45 px targets, accessible names, and automated WCAG checks; +- no-JavaScript system styling, visible navigation, and GET search submission; - Chromium, Firefox, and WebKit; - refreshed dark/light mobile screenshots for visual approval.