From 9666b875164581b67e5d75cf26aa05753e83e49e Mon Sep 17 00:00:00 2001 From: Exotic <118054752+extoci@users.noreply.github.com> Date: Wed, 12 Aug 2026 23:43:40 +0300 Subject: [PATCH] fix(web): preserve appearance mode when changing themes (#6343) --- apps/web/src/hooks/useTheme.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/web/src/hooks/useTheme.ts b/apps/web/src/hooks/useTheme.ts index 68de5d474caef831b22489acb7b5806005741283..8696e41b71d148722591c8df56b1b7a4d42c01e7 100644 --- a/apps/web/src/hooks/useTheme.ts +++ b/apps/web/src/hooks/useTheme.ts @@ -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. -- 2.54.0