docusaurus
docusaurus copied to clipboard
Changing the system theme resets the Docusaurus theme to the default
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [ ] I have tried the
npm run clear
oryarn clear
command. - [ ] I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - [X] I have tried creating a repro with https://new.docusaurus.io.
- [ ] I have read the console error message carefully (if applicable).
Description
When the system colour theme changes (the prefers-color-scheme
media query changes, that is), a Docusaurus site with respectPrefersColorScheme
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.
- Put the system in light mode (steps vary based on OS; in essence, make sure the media query
prefers-color-scheme: light
is true) - Click the theme change button to set the Docusaurus site to dark mode
- Put the system into dark mode (
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
- Public source code: See the repro link above
- Public site URL: In addition to the repro, I first discovered this issue when using docs.cypress.io
- Docusaurus version used: 2.4.0
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Firefox 112.0.2
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS 13.3.1
Self-service
- [ ] I'd be willing to fix this bug myself.