Skip to content

fix(EmptyButton): show a focus ring on keyboard focus - #1344

Merged
XOP merged 3 commits into
ClickHouse:mainfrom
chad-agent:chad/2026-12-01-emptybutton-focus-ring
Dec 2, 2026
Merged

XOP merged 3 commits into
ClickHouse:mainfrom
chad-agent:chad/2026-12-01-emptybutton-focus-ring

Conversation

@chad-agent

@chad-agent chad-agent commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

Close buttons in dialogs now show a ring when you reach them with the keyboard.

  • Before, the close button of Dialog, ConfirmationDialog and Flyout showed nothing when it had keyboard focus.
  • Now it shows the same ring as IconButton: blue in light mode, yellow in dark mode.
  • Screenshot tests that catch a dialog just after it opens will show the ring, because the dialog puts focus on the close button.
  • No app code has to change.

Description

  • EmptyButton drew no focus indicator. It now draws a 2px ring (--click-global-color-outline-default, offset 2px) on :focus-visible.
  • Dialog, ConfirmationDialog and Flyout close buttons show the IconButton ring. The Collapsible trigger keeps the fix(Collapsible): show focus ring on keyboard focus of the trigger #1312 ring.
  • dialog.spec.ts and flyout.spec.ts got a Tab test for outline-style: solid. Both fail on main.

Links and tickets

Good to know

  • The 25 snapshots that show the ring are updated. A dialog focuses its close button on open, so the ring shows. Against main, only ring pixels change (list under Accessibility).
  • CI runs the whole visual suite, because other components import EmptyButton.
  • AGENTS.md §6 discourages :where(). This file already uses it, so class rules can still override the ring.

Checklist

  • Breaking changes? (add migration notes in changesets)
  • Visual changes? (specify in changesets)
  • Design review needed?

Not breaking: no prop, type or export changes. Visual: the close buttons of Dialog, ConfirmationDialog and Flyout show a ring on keyboard focus; the changeset says so and says what to check. No design review: it is the ring IconButton already uses, from the --click-global-color-outline-default token.

Contribution

  • Sufficient research before PR
  • Self-reviewed the PR
  • Manually tested the changes (when applies - visual confirmation in Storybook)
  • build and build-storybook work locally
  • Tests and Stories are aligned with the changes

Not done: a manual check in the Storybook UI. I checked the ring with a Playwright probe on static Storybook builds instead (see Accessibility). No story changed.

Accessibility

  • Keyboard - every action works with Tab / Enter / Space / Esc; focus is visible and returns to the trigger on close
  • Names — every control has a name that includes its visible label; icon-only controls take aria-label
  • Vision — colors come from tokens, focus ring shows, targets are at least 24×24 px

Vision is ticked for the close buttons in this PR: the ring color is a token, the ring shows, and the buttons are 32×32 px (28×28 px in the inline Flyout). Keyboard is not ticked: I tested that Tab reaches the close button and that focus is visible, but not Enter, Space, Escape or focus return, which this PR does not change. Names is not ticked: the Dialog close button has no name on main. #1322 "fix(Dialog): name the header close button and forward its test id" fixes it.

WCAG 2.2 criteria checked: 2.4.7 Focus Visible (AA), 1.4.11 Non-text Contrast (AA) for the ring.

Tested (Chromium 159 in mcr.microsoft.com/playwright:v1.65.1-noble, static Storybook builds of main c39edcf and this branch, light and dark):

  • Focus probe, keyboard focus by Tab, 10 close-button cases: display-dialog--modal-dialog, display-dialog--only-close, display-confirmationdialog--with-close, display-flyout--open-default, display-flyout--inline-type.
    • main: outline-style: none, and the focused and unfocused screenshots are byte-identical, so nothing marks focus.
    • This branch: solid 2px ring, offset 2px, painted on all four sides, not clipped. Light: #437eef, 3.84:1 against the #ffffff dialog background. Dark: #faff69, 15.40:1 against #1f1f1c (Dialog) and 13.74:1 against #282828 (Flyout).
  • Same probe, 20 sidebar trigger cases (SidebarCollapsibleItem and SidebarCollapsibleTitle, focus and focus with hover): same result on both sides, the inset ring from fix(Collapsible): show focus ring on keyboard focus of the trigger #1312, 3.40:1 or more in light, 12.66:1 or more in dark, no clip. Screenshots byte-identical.
  • The two new Playwright tests fail on main and pass on this branch.
  • Visual specs for EmptyButton, CrossButton, Dialog, ConfirmationDialog, Flyout, SidebarCollapsibleItem and SidebarCollapsibleTitle: 84 passed after the 25 baselines below were updated. yarn test:visual cannot build its image here, so I ran the same specs in the stock image with CI=true. The 25 updated baselines:
    • emptybutton-focus-light (1). The old baseline shows the focused button with no ring.
    • dialog-modal, dialog-with-description, dialog-only-close, dialog-reduce-padding, light and dark (8).
    • flyout-open-default, flyout-inline-type, flyout-align-start, flyout-no-shadow, flyout-size-narrow, flyout-size-wide, flyout-size-widest, flyout-body-align-top, light and dark (16).
  • The 25 new baselines match the CI screenshots of this branch pixel for pixel. Against main rendered in the same image, only ring pixels change. 9 of them also pick up drift that main already has, below the Playwright threshold and outside the ring: 7 dialog files, flyout-align-start-dark and flyout-size-wide-dark. main rendered in this image differs from its own baselines in 12 files.
  • Screenshots of main and this branch, taken with the specs' own steps and compared directly: every changed pixel is inside the ring box around the close button (40×40 px, 36×36 px for inline-type). main against main gives 0 changed pixels. title-only, no-header and chat-dialog have no close button and show 0 changed pixels. All 6 ConfirmationDialog stories show 0 changed pixels too, because the close button does not have focus when they open.
  • The full pre-PR chain from AGENTS.md section 2 passes (916 unit tests). eslint-suppressions.json did not change.

Repro without my tools: open iframe.html?id=display-dialog--only-close&globals=theme:light, press Tab once, and look at the edge of the close button.

Not tested:

  • Firefox, Safari, forced colors (Windows High Contrast) and screen readers.
  • axe: it does not check focus visibility, and this PR changes no role, name or markup.
  • A real app layout: a story has no sticky header, so 2.4.11 Focus Not Obscured is not checked beyond the story.

Screenshots

image image

🤖 Generated with Claude Code


Note

Low Risk
Small CSS accessibility fix on a shared primitive; main risk is expected visual snapshot updates when dialogs open with focus on the close control.

Overview
EmptyButton now paints a keyboard focus ring (:focus-visible, 2px --click-global-color-outline-default, offset 2px) via a zero-specificity :where() rule so consumers like CrossButton can still override it.

That restores visible focus on close buttons built on EmptyButton in Dialog, ConfirmationDialog, and Flyout—matching IconButton—where the base style had removed the outline entirely. Playwright accessibility tests in dialog.spec.ts and flyout.spec.ts assert outline-style: solid after Tab; visual snapshots that catch dialogs right after open may show the ring because focus lands on the close button.

Reviewed by Cursor Bugbot for commit 021db6b. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Gareth Jones <305167+gjones@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XOP XOP added enhancement New feature or request a11y Accessibility improvements labels Dec 2, 2026
@XOP XOP self-assigned this Dec 2, 2026
@XOP
XOP marked this pull request as ready for review December 2, 2026 10:06
@mdevils

mdevils commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

@chad-agent could you please include screenshots?

@XOP

XOP commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@mdevils he can't ( I will be meat proxy for now. Screenshots are uploaded

The ring is the one IconButton already uses: #437eef in light (3.84:1 on white) and #faff69 in dark (15.40:1 on the Dialog, 13.74:1 on the Flyout).
The 25 red visual-regression snapshots show this same ring, as listed in the description. I haven't touched the baselines.

chad-agent and others added 2 commits December 2, 2026 13:53
While the Flyout width animation runs, the narrow body overflows and
Chromium makes it a Tab stop. Three Tabs then ended on Test Primary
instead of the close button. The test now waits for the dialog's
animations to finish before it presses Tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… ring

The ring on the close button is the intended look, confirmed in review
(AGENTS.md section 8). A dialog focuses its close button on open, so 25
snapshots of EmptyButton, Dialog and Flyout now show the ring.

Against main rendered in the same image, only pixels inside the ring box
change. Nine of the files also pick up drift below the Playwright
threshold that main already has. The new files match the CI screenshots
of this branch pixel for pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Chromatic Storybook

Check Status Link
Storybook ✅ 672 stories published Open Storybook
UI Tests ⏳ 12 changes must be accepted as baselines Open build

Built from commit: 021db6be4bb023f831b4f7aa0be939c963c144a1 · Chromatic run

Statuses as of the end of the run. The build link shows the live review state.

@XOP
XOP merged commit 5615df2 into ClickHouse:main Dec 2, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a11y Accessibility improvements enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants