facebook / facebook/docusaurus

Changing the system theme resets the Docusaurus theme to the default

Abierto
#8,938 6 comentarios 0 reacciones 0 asignados Ver en GitHub
bug domain: theme
Lenguaje dominante
TypeScript
Estrellas
66.2k
Forks
10k
Merge medio
1 d 3 h
PR fusionados (30 d)
52

Descripción

### 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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.