fix: update ColourSchemeButton and dev index to fix flash#250
Merged
Conversation
Collaborator
|
Looks good to me, I was actually dealing with this a couple of minutes ago, so I can confirm it does work as described for SSR apps |
gfrn
approved these changes
Jul 3, 2026
Contributor
|
@VictoriaBeilsten-Edmands Thank you. I've added also the CSS updates to the button, have you seen that? |
Collaborator
Author
If it's a styling/CSS update, it should be in its own PR. |
Contributor
|
@VictoriaBeilsten-Edmands This was to remove the flashing from the MRT on change |
Collaborator
Author
|
I'm not sure what you mean. |
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.
This PR:
InitColorSchemeScriptin SSR applications.ColourSchemeButtonto avoid rendering while the colour scheme is unresolved.ColourSchemeButtontests to reflect the use of dark (moon) icon in light mode.Dark mode flicker was being caused by the page initially rendering without a data-mode attribute. The default light token set was applied before React and MUI restored the user's saved preference. The script applies the correct mode before the first paint. The
ColourSchemeButtonnow waits for MUI to resolve the active mode before rendering, avoiding initially showing the wrong icon. PlacingInitColorSchemeScriptin main.tsx is not correct as it runs too late after React has mounted.Flash still visible in the dev app because Vite injects CSS dynamically via JavaScript during development for fast HMR, but production builds extract and load CSS ahead of app rendering. We may want to look into extracting css file. See https://www.xjavascript.com/blog/how-to-extract-css-as-a-separate-css-file-in-vite/