Repository navigation
fix(a11y): add skip link to bypass the navigation - #46452
sadpandajoe wants to merge 3 commits into
Conversation
Superset's app shell had no bypass mechanism, so keyboard and screen-reader users had to tab through the whole top navigation on every page before reaching the content (WCAG 2.1 SC 2.4.1, Level A). Render a "Skip to main content" link as the first element of the app shell, ahead of the navigation, and give the shell's Layout.Content (antd renders it as the <main> landmark) id="main-content" as its target. The link is hidden with translateY(-100%) so it stays fully off-screen at any text size and moves into view on focus. Activating it focuses the main landmark through a temporary tabindex="-1", and the landmark suppresses the outline of that programmatic focus. Co-authored-by: Fedo Hagge-Kubat <office@aitema.org> Co-authored-by: Kolja <kolja@aitema.de> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| export const mainContentFocusCss = css` | ||
| &[tabindex='-1']:focus, | ||
| &[tabindex='-1']:focus-visible { | ||
| outline: none; | ||
| } | ||
| `; |
There was a problem hiding this comment.
Suggestion: When the main region is already visible, activating the link hides the focused link and leaves the focused landmark without a visible focus cue.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Possible bug
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/views/App.tsx
**Line:** 177:182
**Comment:**
*Possible Bug: When the main region is already visible, activating the link hides the focused link and leaves the focused landmark without a visible focus cue.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46452 +/- ##
==========================================
- Coverage 86.23% 86.17% -0.06%
==========================================
Files 3146 3141 -5
Lines 220018 219508 -510
Branches 52110 51860 -250
==========================================
- Hits 189725 189159 -566
- Misses 26823 26879 +56
Partials 3470 3470
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gabotorresruiz
left a comment
There was a problem hiding this comment.
@sadpandajoe LGTM, thanks for closing this gap. The red sharded-frontend-tests shards (TreeTable and RangeFilterPlugin) and the literal_percent unit test fail the same way on master, so they're unrelated.
|
|
||
| return ( | ||
| <Flex vertical css={isPanelOpen ? lockedShellCss : pageScrollShellCss}> | ||
| <SkipLink /> |
There was a problem hiding this comment.
Question, not a blocker: MenuWrapper renders nothing when standalone is set or uiConfig.hideNav is on (Menu.tsx lines 579-580), but the skip link still renders, so a standalone dashboard gets a first tab stop that has no nav to skip. Should it follow the same check?
SUMMARY
Supersedes #39240.
Superset's app shell has no bypass mechanism (WCAG 2.1 SC 2.4.1 Bypass Blocks, Level A). In
superset-frontend/src/views/App.tsxthe first thing the shell renders is the navigation (MenuWrapper, a<header>), and the page content sits in aLayout.Contentwith no id. Keyboard and screen-reader users therefore have to tab through the whole top navigation on every page before reaching the content. This is a long-standing gap rather than a regression; no specific introducing change identified (git log -Sfinds no earlier skip link ormain-contenttarget).This PR:
SkipLinkcomponent (src/components/Accessibility/SkipLink.tsx) and renders it as the first element of the app shell, ahead of the navigation. The label is translated (t('Skip to main content'), added tomessages.pot).Layout.Contentid="main-content"as the link's target. antd already rendersLayout.Contentas a<main>element, so the target is the page's main landmark; no extraroleis needed.transform: translateY(-100%)rather than a fixed negative offset, so it stays fully off-screen at any text size and moves into view on focus.tabindex="-1"that is removed again on blur (restoring the element's original markup;-1never puts it in the tab order), and suppresses the outline of that programmatic focus so the whole content area doesn't flash an outline.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
There is no before state to show: without this change Superset renders no skip link at all, so the first Tab lands in the navigation. Both screenshots below are the after state (this branch on SQLite with the examples DB, Dashboards list).
After: the first Tab after loading the page brings up the focused "Skip to main content" link above the navigation
After: pressing Enter moves focus to the
<main>content area (the page scrolls to it, with no outline drawn around it)TESTING INSTRUCTIONS
mainlandmark is listed.ADDITIONAL INFORMATION
Note: #46395 also creates
src/components/Accessibility/with anindex.tsxbarrel (forVisuallyHidden), while this PR usesindex.ts. Git will not flag a conflict between the two, so whichever lands second should fold both exports into a singleindex.ts.Notes (non-blocking review observations, left as they are):
App.test.tsxchecks that the skip link comes before the<main>landmark, not before the nav<header>; in the code nothing focusable precedes it.mainContentFocusCss(the file's existingpageScrollShellCsspattern) rather than rendered behaviour.not.toHaveStyle({ top: '-100px' })assertion inSkipLink.test.tsxis a guard against the old fixed-offset approach.SkipLink.tsxcomment says "just above the viewport"; it is positioned above the top of the document, with the same behaviour.🤖 Generated with Claude Code