Skip to content

Fix transition animation flicker through ColourSchemeButton - #251

Merged
zoharma merged 1 commit into
mainfrom
zma/fix-ColourSchemeButton-mode-flash
Jul 16, 2026
Merged

Fix transition animation flicker through ColourSchemeButton#251
zoharma merged 1 commit into
mainfrom
zma/fix-ColourSchemeButton-mode-flash

Conversation

@zoharma

@zoharma zoharma commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Switching between light and dark mode caused a noticeable flicker as components transitioned before the new colour scheme had fully applied. This happened in internal components such as Chips and external ones such as Material React Table.

This fix adds a temporary ds-mode-changing class during colour scheme changes to suppress CSS transitions and animations until the new theme has been applied, reducing flicker during mode switching.

The CSS and the class were added to the ColourSchemeButton directly.

@zoharma zoharma changed the title Fix transition animation through ColourSchemeButton Fix transition animation flicker through ColourSchemeButton Jul 3, 2026
@zoharma
zoharma marked this pull request as ready for review July 3, 2026 11:13
@zoharma zoharma added the v0.6.2 label Jul 7, 2026
@zoharma
zoharma requested review from douglaswinter and gfrn July 7, 2026 15:04
@NKatti2011
NKatti2011 self-requested a review July 10, 2026 13:11

@NKatti2011 NKatti2011 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure we should have the "temporary" solution that may affect other components unintentionally, or pause unrelated animations, since you're setting a global style rule through a component. This change should live at the theme provider / colour scheme context level instead. Please add debounce for double-click instances, and clear timeout on rapid clicks. The 250ms timeout is arbitrary and may cause intermittent issues in other apps depending on tree size.

@zoharma
zoharma force-pushed the zma/fix-ColourSchemeButton-mode-flash branch 3 times, most recently from cb1ad58 to 18efe94 Compare July 10, 2026 17:52
@zoharma
zoharma requested a review from NKatti2011 July 10, 2026 17:54
@zoharma

zoharma commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@NKatti2011 Have moved the colour scheme transition suppression to ThemeProvider

@NKatti2011

Copy link
Copy Markdown
Collaborator

Fix(ThemeProvider): suppress transition flicker on colour-scheme change via data-mode observer. uses MutationObserver watching the html[data-mode] attribute directly so ensures flicker suppression tirggers for any mode change source, not just through a specific component. Debounces for rapid toggles. Suppression logic is fully moved to ThemeProvider, where ColourSchemeButton has no more Dom/class manipulation of its own. Adds modeTransitionSuppressionMs param so timeout is not hardcoded.

@zoharma
zoharma force-pushed the zma/fix-ColourSchemeButton-mode-flash branch from 89de836 to 3f4cd87 Compare July 14, 2026 13:46
@zoharma

zoharma commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@NKatti2011 Alright, thanks for that! I've updated the timeout handling to use explicit undefined checks.

@zoharma
zoharma force-pushed the zma/fix-ColourSchemeButton-mode-flash branch 2 times, most recently from 7d17aea to 429f38f Compare July 16, 2026 11:08
* Add transition flicker suppression when the colour scheme changes.
* Add a `MutationObserver` that watches `html[data-mode]`, allowing suppression to work regardless of what triggers the mode change.
* Add debouncing to handle rapid colour scheme toggles.
* Move all transition suppression logic into `ThemeProvider`.
* Remove transition suppression DOM/class manipulation from `ColourSchemeButton`.
* Add a configurable `modeTransitionSuppressionMs` prop instead of using a hardcoded timeout.
* Update the colour scheme transition animation in `ColourSchemeButton`.
* Use explicit `undefined` checks when cleaning up the suppression timeout.
@zoharma
zoharma force-pushed the zma/fix-ColourSchemeButton-mode-flash branch from 429f38f to ce4cd7d Compare July 16, 2026 11:13
@zoharma
zoharma merged commit 5c32edd into main Jul 16, 2026
2 checks passed
@zoharma zoharma added this to the DS Release milestone Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants