Repository navigation
fix(Button): stop looking pressed after a mouse click - #1328
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: f8d8dd1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
XOP
approved these changes
Nov 30, 2026
DreaminDani
approved these changes
Nov 30, 2026
Contributor
Chromatic Storybook
Built from commit: Statuses as of the end of the run. The build link shows the live review state. |
8 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
After a mouse click,
Buttonkeeps 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-visibleand kept the look, as a migration should.:focus:not(:focus-visible, :disabled)selector from the pressed-style rule ofprimary,secondary,emptyanddanger. The pressed style now shows only while the button is held down.:activestyle, the:focus-visiblering and fill, and the disabled and loading styles.Links and tickets
Closes #524
Good to know
Button.module.css(4 selectors removed), no token edits. The existingButtonandButtonGrouptests pass (35).AGENTS.mdpasses locally, plusbuild:health_check.IconButton(:focus,:focus-within) andSplitButton(:focus) have the same pressed-after-click pattern. I think those can go in as separate prs.Checklist
Buttonreturns to its normal or hover colors on release; described in the changeset.Contribution
buildandbuild-storybookwork locallyAccessibility
Tested on Zen Browser v1.24.2b (Firefox-based) on Linux, on the
PrimarystoryScreenshots
Click, then move the pointer away (
Primary, dark theme) the dark color doesn't go away until clicked outside:Keyboard focus is unchanged:
Note
Low Risk
CSS-only interaction styling in
Button.module.css; no logic, tokens, or accessibility behavior changes beyond correcting mouse click appearance.Overview
Mouse-clicked
Buttons no longer keep pressed styling after release. Forprimary,secondary,empty, anddanger, the pressed look was tied to both:activeand:focus:not(:focus-visible)—so a click left the button focused (without:focus-visible) and stuck in the pressed colors until focus moved. The:focus:not(:focus-visible, :disabled)part of those rules is removed; pressed styling applies only under:active.:focus-visiblestyling is unchanged, so keyboard focus still shows the focus ring and active fill. A patch changeset documents the visual fix.Reviewed by Cursor Bugbot for commit f8d8dd1. Bugbot is set up for automated code reviews on this repo. Configure here.