Skip to content

Commit 75081d7

Browse files
committed
fix(web): preserve appearance mode when changing themes
1 parent b73232b commit 75081d7

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎apps/web/src/hooks/useTheme.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ export function useTheme() {
473473
const setTheme = useCallback((next: Theme): boolean => {
474474
if (typeof window === "undefined") return false;
475475
try {
476+
// Preserve the current mode before replacing a legacy or inferred theme
477+
// preference. Otherwise a fresh System preference is re-inferred from
478+
// the new theme's base appearance, which can switch a dark UI to light.
479+
writeAppearanceModePreference(readAppearanceModePreference(getStored()));
476480
// Choosing a whole theme replaces any automatic-mode mix. The mix is
477481
// captured first so a failed preference write can put it back instead
478482
// of erasing it or leaving it attached to the new theme.

0 commit comments

Comments
 (0)