-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing the system theme resets the Docusaurus theme to the default #8938
Comments
From initial debugging - Irrespective of respectPrefersColorScheme value, every time the system theme is changed, the localstorage value is deleted and so default value(light theme) is set. May I work on this ? |
On further deep dive in the codebase, this proves to be a conscious and expected behavior. |
The problem is that there exists a user action here (setting the mode to dark), so I'd expect it to persist. It's the exact opposite situation as in #7199 (where the button is disabled but |
#7200 (comment) - this thread here seemed to have agreed on with prioritizing the OS triggered color even when user action is setting to dark mode and also about persist option being unused. As per what I understand from code, if and when there is a change in the system color mode, window.matchMedia onchange is triggered and the |
I think there's scope for improving the behaviour, even if it was intended. To me it doesn't make sense that changing the system theme at all should always put a site into light mode. |
Mmm, I think the key is |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
When the system colour theme changes (the
prefers-color-scheme
media query changes, that is), a Docusaurus site withrespectPrefersColorScheme
off sets the theme back to the default, regardless of the system theme or the current site theme as set by the user.Reproducible demo
https://codesandbox.io/p/sandbox/github/facebook/docusaurus/tree/main/examples/classic
Steps to reproduce
A fresh installation of Docusaurus should work, or the codesandbox.io link above.
prefers-color-scheme: light
is true)prefers-color-scheme: dark
is true)Expected behavior
Given that
respectPrefersColorScheme
is off, I'd expect the theme not to change when the system colour scheme changes.Actual behavior
The theme is reset to the default – light mode in the case of the repro link.
Your environment
Self-service
The text was updated successfully, but these errors were encountered: