fix(web): preserve appearance mode when changing themes (#6343)

This commit is contained in:
Exotic authored and GitHub committed 2026-08-12 16:43:40 -04:00
1 parent e3a9c2518d
commit 9666b87516
1 file changed
+4
+4
View File
@@ -473,6 +473,10 @@ export function useTheme() {
const setTheme = useCallback((next: Theme): boolean => {
if (typeof window === "undefined") return false;
try {
// Preserve the current mode before replacing a legacy or inferred theme
// preference. Otherwise a fresh System preference is re-inferred from
// the new theme's base appearance, which can switch a dark UI to light.
writeAppearanceModePreference(readAppearanceModePreference(getStored()));
// Choosing a whole theme replaces any automatic-mode mix. The mix is
// captured first so a failed preference write can put it back instead
// of erasing it or leaving it attached to the new theme.