Skip to content

fix(a11y): add skip link to bypass the navigation - #46452

Open
sadpandajoe wants to merge 3 commits into
masterfrom
ultraset-skip-link-keyboard-bypass-blocks
Open

sadpandajoe wants to merge 3 commits into
masterfrom
ultraset-skip-link-keyboard-bypass-blocks

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

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.tsx the first thing the shell renders is the navigation (MenuWrapper, a <header>), and the page content sits in a Layout.Content with 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 -S finds no earlier skip link or main-content target).

This PR:

  • Adds a SkipLink component (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 to messages.pot).
  • Gives the shell's Layout.Content id="main-content" as the link's target. antd already renders Layout.Content as a <main> element, so the target is the page's main landmark; no extra role is needed.
  • Hides the link with 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.
  • On activation, focuses the main landmark through a temporary tabindex="-1" that is removed again on blur (restoring the element's original markup; -1 never 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: 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)

After: focus moved to the main content area

TESTING INSTRUCTIONS

  1. Open any page (e.g. Dashboards list, a dashboard, SQL Lab) and click once in the browser's address bar, or reload, so focus starts at the top of the page.
  2. Press Tab: a "Skip to main content" link appears at the top-left, above the navigation bar.
  3. Press Enter: focus moves to the page content (the next Tab lands on the first control in the content, not in the navigation), and no outline is drawn around the content area.
  4. Press Tab from a fresh load and then Shift+Tab / click elsewhere: the link is not visible unless it has keyboard focus, including with the browser's text size or zoom increased.
  5. With a screen reader, confirm the link is announced first and that a main landmark is listed.
  6. With the chat panel open (ENABLE_EXTENSIONS and a chat extension), repeat steps 2-3: the link still moves focus to the content panel.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Note: #46395 also creates src/components/Accessibility/ with an index.tsx barrel (for VisuallyHidden), while this PR uses index.ts. Git will not flag a conflict between the two, so whichever lands second should fold both exports into a single index.ts.

Notes (non-blocking review observations, left as they are):

  • App.test.tsx checks that the skip link comes before the <main> landmark, not before the nav <header>; in the code nothing focusable precedes it.
  • The outline test asserts the text of the exported mainContentFocusCss (the file's existing pageScrollShellCss pattern) rather than rendered behaviour.
  • The not.toHaveStyle({ top: '-100px' }) assertion in SkipLink.test.tsx is a guard against the old fixed-offset approach.
  • The SkipLink.tsx comment says "just above the viewport"; it is positioned above the top of the document, with the same behaviour.

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the i18n Namespace | Anything related to localization label Nov 21, 2026
Comment on lines +177 to +182
export const mainContentFocusCss = css`
&[tabindex='-1']:focus,
&[tabindex='-1']:focus-visible {
outline: none;
}
`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

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
👍 | 👎

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟡  Medium Risk

  • The PR needs attention before merging.
  • The main landmark suppresses its focus outline, so activating the skip link can leave keyboard users without a visible indication of their new focus.

Assessed commit: 53eb5de09f91

@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.17%. Comparing base (9969fe9) to head (53eb5de).

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              
Flag Coverage Δ
hive 33.63% <ø> (ø)
mysql 51.83% <ø> (ø)
postgres 51.85% <ø> (-0.01%) ⬇️
presto 35.32% <ø> (ø)
python 88.81% <ø> (ø)
sqlite 51.55% <ø> (ø)
unit 84.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i18n Namespace | Anything related to localization size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants