fix(a11y): keep keyboard-focused search suggestion visible (WCAG 2.4.11)#412
Open
WanjohiSammy wants to merge 2 commits into
Open
fix(a11y): keep keyboard-focused search suggestion visible (WCAG 2.4.11)#412WanjohiSammy wants to merge 2 commits into
WanjohiSammy wants to merge 2 commits into
Conversation
The navbar search box was driven by two keyboard navigators at once (legacy Swiftype and the ARIA ComboboxAutocomplete), and the suggestion list had no height cap so the whole page scrolled to reveal lower options. Together these let the keyboard-focused suggestion be obscured. Cap the suggestion list to the viewport and scroll it internally (the standard ARIA combobox pattern) so the page never scrolls and the input stays in view, and make the combobox the single navigator that keeps the visible highlight in sync with aria-selected. Enter still selects the highlighted suggestion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WCAG 2.4.11 Focus Not Obscured (Minimum). When a user types in the top-navbar search box and arrows through the autocomplete suggestions, the keyboard-focused suggestion could be scrolled off-screen (obscured), because the page does not reliably keep it in view. This is most visible on short or zoomed-in viewports where the suggestion list is taller than the visible area.
This completes the earlier partial fix in #406 (
scroll active search suggestion into view), which did not fully resolve the issue across browsers and arrow directions.Root cause
The navbar search input is driven by two keyboard navigators at once:
jquery.swiftype.autocomplete.js) - owned the visible highlight (activeclass) and Enter selection.combobox-autocomplete.js) - ownsaria-selected/aria-activedescendantand scroll-into-view.Fix
Make the suggestion list scroll internally (the standard ARIA combobox pattern) and make the combobox the single keyboard navigator.
Before
After