mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user