Skip to content

fix(Button): stop looking pressed after a mouse click - #1328

Open
marsian83 wants to merge 1 commit into
ClickHouse:mainfrom
marsian83:fix/button-pressed-after-click
Open

marsian83 wants to merge 1 commit into
ClickHouse:mainfrom
marsian83:fix/button-pressed-after-click

Conversation

@marsian83

@marsian83 marsian83 commented Nov 25, 2026 •

Copy link
Copy Markdown

Description

After a mouse click, Button keeps its pressed colors until focus moves somewhere else (#524).
Each variant styles :focus:not(:focus-visible, :disabled) the same as :active.
A mouse click focuses the button without :focus-visible, so when the mouse is released the pressed style stays.

The pressed style also beats hover: .button_primary:hover:not(:disabled) and the focus selector have the same specificity, and the focus rule comes later, so a clicked button still looks pressed while the pointer is over it.

This goes back to the styled-components Button, which applied the pressed style on &:active, &:focus. The CSS Modules setup in #810 narrowed it to focus that isn't :focus-visible and kept the look, as a migration should.

  • Removed the :focus:not(:focus-visible, :disabled) selector from the pressed-style rule of primary, secondary, empty and danger. The pressed style now shows only while the button is held down.
  • Unchanged: the :active style, the :focus-visible ring and fill, and the disabled and loading styles.

Links and tickets

Closes #524

Good to know

  • CSS-only change in Button.module.css (4 selectors removed), no token edits. The existing Button and ButtonGroup tests pass (35).
  • The full pre-PR chain from AGENTS.md passes locally, plus build:health_check.
  • The full Docker visual suite passes (1275 tests) with no snapshot changes.
  • IconButton (:focus, :focus-within) and SplitButton (:focus) have the same pressed-after-click pattern. I think those can go in as separate prs.

Checklist

  • Breaking changes? (add migration notes in changesets)
  • Visual changes? (specify in changesets) A clicked Button returns to its normal or hover colors on release; described in the changeset.
  • Design review needed?

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: CSS-only, see "Good to know".

Accessibility

  • Keyboard - focus with Tab still works as before
  • Vision - no color changes

Tested on Zen Browser v1.24.2b (Firefox-based) on Linux, on the Primary story

Screenshots

Click, then move the pointer away (Primary, dark theme) the dark color doesn't go away until clicked outside:

Before After
before click after click

Keyboard focus is unchanged:

after keyboard


Note

Low Risk
CSS-only selector tweak in Button.module.css with no JS or token changes; keyboard :focus-visible behavior is preserved.

Overview
Fixes a visual bug where Button stayed in its pressed (active) colors after a mouse click until focus moved elsewhere (#524).

For primary, secondary, empty, and danger variants in Button.module.css, the pressed styling rule no longer includes :focus:not(:focus-visible, :disabled)—only :active:not(:disabled) applies the active colors. Mouse clicks still focus the button, but without :focus-visible that focus no longer keeps the pressed look after release; hover returns as expected.

:focus-visible keyboard focus rings and fills are unchanged. A patch changeset documents the visual behavior update.

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

@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fa4d72d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@marsian83
marsian83 marked this pull request as ready for review November 25, 2026 17:36
@XOP
XOP requested review from DreaminDani and XOP November 26, 2026 09:31
@XOP XOP added the bug Something isn't working label Nov 26, 2026
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Chromatic Storybook

Check Status Link
Storybook ✅ 672 stories published Open Storybook
UI Tests ✅ 672 tests unchanged Open build

Built from commit: fa4d72dd0202b482b986b003024d13a3dc37a638 · Chromatic run

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

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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

button component feels like it gets "stuck" after clicking

2 participants