Skip to content

fix(a11y): show a visible keyboard focus ring on interactive controls - #46396

Merged
sadpandajoe merged 3 commits into
masterfrom
ultraset-visible-keyboard-focus-interactive-elements
Nov 21, 2026
Merged

sadpandajoe merged 3 commits into
masterfrom
ultraset-visible-keyboard-focus-interactive-elements

Conversation

@sadpandajoe

Copy link
Copy Markdown
Member

SUMMARY

Supersedes #39242.

Keyboard focus is not visible on several interactive controls (WCAG 2.1 SC 2.4.7, Focus Visible). The cause is component CSS that removes the browser's focus outline and puts nothing in its place. No specific introducing change was identified; each of these rules predates the AntD v6 upgrade (#41636).

  • Filter Badge popover items (FiltersBadge/Styles.tsx): FilterItem sets outline: none, so arrowing through the applied filters shows no focus. The comment added by fix(dashboard): remove stray focus outline on Filter Badge popover (closes #38789) #41398 already says these items provide their own :focus-visible style; this adds it.
  • Conditional formatting remove button (ConditionalFormattingControl.tsx): outline: none with no replacement.
  • Viz type gallery (VizTypeGallery.tsx): the category tabs used &:focus { outline: initial }, which resets outline-style to none. The thumbnail buttons used outline: none.
  • Legacy filter scope selector (FilterScopeSelector.tsx, "Set filter mapping"): react-checkbox-tree makes every node title a focusable span.rct-node-clickable (tabIndex={0}), and its stylesheet sets outline: 0 on focus, relying on a background tint instead. Superset's override then removes that tint (background: none !important), so a focused node shows nothing at all. The override stays, and the node titles get a :focus-visible outline.
  • InfoTooltip trigger: &&&:focus { outline: none } overrode AntD v6's own Button :focus-visible ring. Dropping that one declaration lets AntD's ring show. AntD's base .ant-btn { outline: none } still keeps mouse clicks ring-free.

The new rings use the existing local pattern from HeaderGroupsControl (:focus-visible { outline: 2px solid colorPrimary }). An outline, unlike a box-shadow, also stays visible in Windows High Contrast / forced-colors mode. The ring is inset (-2px) where the parent clips overflow (the Filter Badge popover) or space is tight. It is outset (2px) in the viz gallery, so it stays distinguishable on the primary-filled selected category.

Unit tests (@emotion/jest toHaveStyleRule with a :focus-visible target) cover the Filter Badge items, the conditional formatting remove button, the viz gallery categories, and the filter scope node titles. The InfoTooltip and viz-thumbnail changes are styled through Emotion's css prop. Jest's babel config does not compile that prop (it reaches the DOM as a plain attribute), so those two are verified manually (steps 2 and 4 below).

Differences from #39242. This PR leaves out the original's global :where(...):focus-visible { outline: … !important } rule in GlobalStyles.tsx. Under the AntD v6 upgrade (#41636) that rule is no longer needed, and it is unsafe:

  1. Its rationale no longer holds. AntD v6 does not ship .ant-btn:focus { outline: 0 }. It ships .ant-btn { outline: none } plus its own :focus-visible outline (genFocusStyle) on Button, Checkbox, Radio, Switch, Tabs, Menu, Dropdown, Pagination and others. Browsers already outline any native element whose author CSS doesn't remove the outline.
  2. Through [tabindex] it matches the Filter Badge popover container (tabIndex={-1}, role="menu"). Its !important would beat that container's outline: none and bring back the stray ring that fix(dashboard): remove stray focus outline on Filter Badge popover (closes #38789) #41398 removed. fix(dashboard): remove stray focus outline on Filter Badge popover (closes #38789) #41398's unit test would stay green, because @emotion/jest cannot see Global styles.
  3. It double-rings AntD v6 Tabs. [role='tab'] sits on .ant-tabs-tab-btn, which AntD deliberately sets to outline: none while it draws the ring on the parent tab.
  4. It double-rings AntD v6 Select. The inner input / [role='combobox'] gets an outline while AntD already outlines the select root via :has(input:focus-visible).
  5. It forces outline-offset: 2px over component rings that need an inset offset (e.g. HeaderGroupsControl). Some of its selectors no longer match anything in v6 (.ant-select-selector was renamed .ant-select-content; .ant-cascader-picker no longer exists).

The original's changes to WithPopoverMenu, RangeFilterPlugin and dashboard/styles.ts are also not carried over. The WithPopoverMenu wrapper is never focused (role="none", no tabIndex). The range filter and the dashboard focusStyle already show a visible ring. In FilterScopeSelector, the original styled the expand/collapse buttons, which already keep the browser's ring. This PR instead adds the ring to the node titles, which had none.

The original's TimeFilterPlugin change (controlOutline → colorPrimary on a :focus > div target) is not carried over either. That selector matches no element in the rendered markup: the filter container's only child is a span, and the keyboard focus target is the date-range button, which already shows the browser's focus ring. The change would not alter anything on the page.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Keyboard focus (Tab / Shift+Tab) in headless Chromium on SQLite with the examples DB. BEFORE is master @ bb88764; AFTER is this branch.

Control Before After
Viz gallery category ("All charts", focused) before: viz gallery category after: viz gallery category
Viz gallery thumbnail ("Bar Chart", focused) before: viz gallery thumbnail after: viz gallery thumbnail
InfoTooltip icon (dashboard edit mode, "Show only my charts") before: InfoTooltip after: InfoTooltip
Conditional formatting remove button before: conditional formatting remove after: conditional formatting remove

The Filter Badge popover items and the legacy filter scope tree were not captured (they need an applied filter or filter_scopes metadata); the unit tests cover their rules.

TESTING INSTRUCTIONS

Use the keyboard only (Tab / Shift+Tab / arrow keys) in a Chromium or Firefox browser:

  1. Dashboard with an applied cross-filter: Tab to the filter count badge on a chart header and press Enter. Use the up/down arrows to move between the listed filters. Each focused item shows a primary-color ring; the popover container itself shows no ring.
  2. Explore → "View all charts": Tab into the left-hand category list. The focused category shows a ring, including the selected (filled) one. Tab into the thumbnail grid; the focused thumbnail shows a ring.
  3. Explore, a Table chart → Conditional formatting: add a rule, then Tab to its "×" remove button. It shows a ring.
  4. Any control with an info ("i") tooltip icon, e.g. the Database connection modal's advanced options: Tab to the icon. It shows AntD's focus ring.
  5. A dashboard whose metadata has filter_scopes (legacy filter mapping): Edit dashboard → "…" menu → "Set filter mapping". Tab through the filter field list on the left and the scope tree on the right. Each focused node title shows a primary-color ring.
  6. Click the same controls with the mouse: no focus ring appears.

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

Notes:

  • The InfoTooltip and viz-thumbnail rings have no unit test (Emotion's css prop is not compiled in jest); they are covered by manual steps 2 and 4.
  • The ring InfoTooltip gets back is AntD's own default focus ring (colorPrimaryBorder). Its contrast against white may be below the 3:1 of WCAG 1.4.11; that is AntD's convention for every button and is left out of scope here.
  • The filter scope regression test mocks the two trees, so it checks the stylesheet rule only; that the nested selector reaches the real .rct-node-clickable markup was checked against react-checkbox-tree 1.8.0's source.
  • FilterItem has padding: 0, so its inset ring can touch the edge of the icon or text (cosmetic).

🤖 Generated with Claude Code

sadpandajoe and others added 3 commits November 19, 2026 23:18
Several focusable controls removed the browser focus outline without
replacing it (WCAG 2.4.7): the Filter Badge popover items, the
conditional formatting remove button, the viz type gallery categories
and thumbnails, and the InfoTooltip trigger, whose &&&:focus rule also
overrode AntD v6's own Button focus ring. Give each a :focus-visible
outline in colorPrimary, following the HeaderGroupsControl pattern,
and drop the InfoTooltip override so AntD's ring shows.

The Time range filter's focus ring used the low-alpha controlOutline
token, below the 3:1 non-text contrast of WCAG 1.4.11; it uses
colorPrimary instead.

No global !important :focus-visible rule is added: AntD v6 already
draws focus rings on its components, and such a rule would re-add the
Filter Badge popover outline removed in #41398 and double-ring AntD
Tabs and Select.

Supersedes #39242.

Co-authored-by: Fedo Hagge-Kubat <fedo.hagge-kubat@aitema.de>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
react-checkbox-tree renders each node title as a focusable
span.rct-node-clickable and its stylesheet sets outline: 0 on focus,
relying on a background tint that FilterScopeSelector then removes with
background: none !important. Keyboard focus on the filter field list
and the scope tree was therefore invisible (WCAG 2.4.7). Add a
:focus-visible outline in colorPrimary next to that override.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The &:focus > div rule in TimeFilterPlugin matches no element: the
filter container's only child is the date-range trigger span, and the
keyboard focus target (the date-range button) already shows the
browser focus ring. Restore TimeFilterPlugin.tsx and its test to
master so the PR no longer touches the Time filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 43ab67f511f4

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.66%. Comparing base (f357ec3) to head (43ab67f).
⚠️ Report is 42 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46396      +/-   ##
==========================================
- Coverage   85.66%   85.66%   -0.01%     
==========================================
  Files        3111     3111              
  Lines      214938   214933       -5     
  Branches    50908    50907       -1     
==========================================
- Hits       184136   184131       -5     
  Misses      27381    27381              
  Partials     3421     3421              
Flag Coverage Δ
javascript 82.34% <ø> (ø)

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.

@aminghadersohi
aminghadersohi self-requested a review November 21, 2026 16:39

@aminghadersohi aminghadersohi 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.

Each new :focus-visible ring matches the element that takes keyboard focus, and each test fails with its rule removed.

@sadpandajoe
sadpandajoe merged commit 7e672a6 into master Nov 21, 2026
109 of 115 checks passed
@sadpandajoe
sadpandajoe deleted the ultraset-visible-keyboard-focus-interactive-elements branch November 21, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants