Repository navigation
Conversation
Hello cuervino,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
|
/changie Enhanced Remove the white flash on page load in dark mode |
Request integration branchesWaiting for integration branch creation to be requested by the user. To request integration branches, please comment on this pull request with the following command: Alternatively, the |
Auto-generated-by: changie-add-changelog
|
✅ Changelog check passed. |
| var light = localStorage.getItem('theme') === 'light'; | ||
| var root = document.documentElement; | ||
| root.style.backgroundColor = light ? '#FCFCFC' : '#121219'; | ||
| root.style.colorScheme = light ? 'light' : 'dark'; |
There was a problem hiding this comment.
These inline styles on <html> are never updated afterwards. When the user switches theme from the navbar (setThemeMode in ShellThemeSelectorProvider.tsx), <html> keeps the old background and color-scheme until reload. In light mode that leaves dark scrollbars, dark native form controls and a dark overscroll area. Fix: update document.documentElement.style.backgroundColor/colorScheme in changeThemeMode (or in an effect on themeMode, using selectedTheme.backgroundLevel1), or remove the inline styles once the app has mounted.
— Claude Code
|
JeanMarcMilletScality
left a comment
There was a problem hiding this comment.
One gap: the script sets background-color and color-scheme on once, at load time, and nothing updates them afterwards. After switching from dark to light
without reloading, keeps the dark background and color-scheme: dark until the next reload.
I suggest letting the provider take over once it mounts, so the values come from the real theme after the first paint:
// ShellThemeSelectorProvider.tsx
useEffect(() => {
const root = document.documentElement;
root.style.backgroundColor = selectedTheme.backgroundLevel1;
root.style.colorScheme = themeMode;
}, [selectedTheme, themeMode]);
Optional: the themes come from config.json, so the two hard-coded colors can drift. The provider could store backgroundLevel1 in
localStorage for the script to read, with the current colors as a fallback for the first visit.
Every page load shows a white flash before the shell renders, even in dark mode. The HTML template sets no background, so the browser paints its default white until React mounts and the theme applies.
This adds a small inline script to
index-template.htmlthat reads the theme already stored byShellThemeSelectorProvider(localStorage.theme, dark by default) and sets the matching background on<html>before anything else loads.The two colors are the
backgroundLevel1of the themes ARTESCA configures (darkRebrandandartescaLight). They are hard-coded because the theme is not available yet at that point.Fixes ARTESCA-18437.