From b7d432794e51f3fa6489c9d76f9a2a8ce0fedfaa Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 6 Sep 2026 01:40:43 +0300 Subject: [PATCH] fix(docs-infra): keep an explicit theme choice when the OS scheme changes `watchPreferredColorScheme` applied the OS scheme unconditionally, while `setTheme`, `loadThemePreference` and the bootstrap script in index.html all only follow it for `auto`. Choosing Light and then letting the OS switch to dark repainted the site dark while the theme menu still reported Light, until a reload restored it. --- adev/src/app/core/services/theme-manager.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/adev/src/app/core/services/theme-manager.service.ts b/adev/src/app/core/services/theme-manager.service.ts index fa795ccd6b2..5458086fb87 100644 --- a/adev/src/app/core/services/theme-manager.service.ts +++ b/adev/src/app/core/services/theme-manager.service.ts @@ -77,6 +77,9 @@ export class ThemeManager { private watchPreferredColorScheme() { window.matchMedia(PREFERS_COLOR_SCHEME_DARK).addEventListener('change', (event) => { + if (this.theme() !== 'auto') { + return; + } const preferredScheme = event.matches ? 'dark' : 'light'; this.setThemeBodyClasses(preferredScheme); });