Skip to content

fix(ToggleButton): switch the checkmark and radio dot at once instead of fading them - #11051

Open
langz wants to merge 3 commits into
mainfrom
fix/toggle-button-indicator-motion
Open

langz wants to merge 3 commits into
mainfrom
fix/toggle-button-indicator-motion

Conversation

@langz

@langz langz commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

With variant="checkbox" or variant="radio", the button changes its background and border at once, but the checkmark or radio dot inside it fades in or out over 200ms. The indicator visibly lags behind the button.

ToggleButton already turned off the transition on the nested checkbox box. It now does the same for the checkmark and the radio dot, so they switch together with the button. Standalone Checkbox and Radio keep their animation.

Before / after

Each row shows the buttons the given time after they were selected.

First (checkbox variant) and Third (radio variant) toggle buttons 0, 50, 100 and 200 ms after being selected. Before: the buttons look selected at once, but the checkmark and radio dot fade in over 200 ms. After: the checkmark and dot are shown at once.

Chip had the same issue and is fixed in #11050.

…ding them

The button changes its look at once, but the nested Checkbox and Radio
fade their indicator over 200ms, so it lags behind the button.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
langz

This comment was marked as outdated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Looks good. The two resets sit next to the existing one on the checkbox box, and the CSS snapshot locks them. Dropping the e2e file also avoids the add/add conflict with #11053, which creates the same file.

@langz langz left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Final review of ae19b03: no critical findings.

  • Adjusted in this round: removed the e2e test. The PR now changes dnb-toggle-button.scss and its CSS snapshot, which differs only by the two transition: none declarations.
  • Verified with the published package instead of the Portal. A standalone Vite + React app installed the npm release (11.18.1), the main build (9365a68) and this PR's build from pkg.pr.new (a2cdbf7, same CSS as this commit). It clicked ToggleButton groups with the checkbox and radio variants in Chromium, Firefox and WebKit, with four ways of loading the styles: all-in-one, isolated style scope, per-component imports with Checkbox and Radio last, and the Sbanken theme.
    • In the release and on main, the checkmark and radio dot fade.
    • With this PR, they don't fade, in every engine and style setup. Standalone Checkbox and Radio still fade, and chips still fade until #11050.
    • Once the selection has settled, every page is pixel-identical to main.
  • The rules ship in dnb-toggle-button.css, the components bundle and every theme bundle, in both the plain and the isolated variant, and outrank the Checkbox and Radio transitions in all of them.
  • CI for this commit was still running when this review was posted.

@langz

langz commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

@joakbjerk Thanks! #11053 also updates ToggleButton.test.tsx.snap, so I checked that as well: the two PRs merge cleanly, and the ToggleButton tests pass with both.

This branch was successfully deployed

2 active deployments
Package preview — ae19b03a Deployed Nov 24, 2026 by github-actions[bot]
Portal preview — ae19b03a Deployed Nov 24, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants