facebook / facebook/docusaurus

Changing the system theme resets the Docusaurus theme to the default

Offen
#8,938 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug domain: theme
Vorherrschende Sprache
TypeScript
Sterne
66.2k
Forks
10k
Ø Merge
1 T. 3 Std.
Gemergte PRs (30 T.)
52

Beschreibung

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [ ] I have tried the `npm run clear` or `yarn 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.

1. Put the system in light mode (steps vary based on OS; in essence, make sure the media query `prefers-color-scheme: light` is true)
2. Click the theme change button to set the Docusaurus site to dark mode
3. 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.