fix(docs-infra): keep an explicit theme choice when the OS scheme changes by erkamyaman · Pull Request #70588 · angular/angular · GitHub
Skip to content

fix(docs-infra): keep an explicit theme choice when the OS scheme changes - #70588

Open
erkamyaman wants to merge 1 commit into
angular:mainfrom
erkamyaman:fix-theme-override-on-os-change
Open

fix(docs-infra): keep an explicit theme choice when the OS scheme changes#70588
erkamyaman wants to merge 1 commit into
angular:mainfrom
erkamyaman:fix-theme-override-on-os-change

Conversation

@erkamyaman

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-09-06.at.13.13.41.mov

Steps to reproduce

  • Set macOS System Settings → Appearance to Dark
  • Open https://angular.dev
  • In the theme menu, pick Dark (matching your OS, so the next step is a single change)
  • Switch System Settings → Appearance to Light

Expected: the site stays dark, since Dark was chosen explicitly.

Actual: the site turns light, and the theme menu still shows the checkmark on Dark.

Confirm in the console:

localStorage.getItem('themePreference')   // "dark"   <- the stored choice
document.documentElement.className         // "docs-light-mode"  <- what was applied

Reloading restores Dark, until the OS changes again. Anyone using macOS Auto appearance hits this unprompted at sunrise and sunset.

After:

Screen.Recording.2026-09-06.at.13.16.13.mov

…nges

`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.
@pullapprove
pullapprove Bot requested a review from alan-agius4 September 6, 2026 10:18
@angular-robot angular-robot Bot added the area: docs-infra Angular.dev application and infrastructure label Sep 6, 2026
@ngbot ngbot Bot added this to the Backlog milestone Sep 6, 2026

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: docs-infra Angular.dev application and infrastructure target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants