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.
This commit is contained in:
Kam
2026-09-06 01:40:43 +03:00
committed by Kristiyan Kostadinov
parent b0cda277da
commit b7d432794e
@@ -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);
});