Skip to content

Automatic detection of dark mode not working when disableSwitch=true #3876

@hmil

Description

@hmil

🐛 Bug Report

Assuming colorMode.respectPrefersColorScheme is set to true,

  • when colorMode.disableSwitch is false, the color theme changes dynamically when the OS setting is changed, without requiring a full page reload.
  • when colorMode.disableSwitch is true, this behavior doesn't work. Instead, the user has to reload the page for the correct color theme to kick in.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Set colorMode.respectPrefersColorScheme to true
  2. Set colorMode.disableSwitch to true
  3. Make sure your localStorage is empty
  4. Change your OS color theme preference, the color theme of Docusaurus is not dyamically updated

Expected behavior

The color theme should change dynamically.

Actual Behavior

🎥 observed behavior
🎥 behavior when toggle is on (for comparison)
🎥 expected behavior

Your Environment

N/A

Reproducible Demo

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions