Skip to content

Switching to 'Dark Mode' by itself when window.print() is called on Chrome #6479

@DogaGencerOSF

Description

@DogaGencerOSF

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

I'm using window.print() to print preview the docs I created. While doing tests, I noticed that when print preview is opened either with window.print() or ctrl+p, the docusaurus site is switched to the dark mode by itself in Chrome browser. I tested it on two different computers and the result is the same. The storage theme value remains in light but for some reason the site goes dark mode.

This only happens if your system wide dark mode setting is on.

Steps to reproduce

  1. Turn OS dark mode setting on
  2. Get into any docusaurus site (https://docusaurus.io/showcase) with Chrome browser
  3. Press ctrl+p or write window.print() in console

Expected behavior

The theme of the site should not change.

Actual behavior

The theme of the site goes dark mode if it were set light to mode.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used: 2.0.0-beta.15
  • Environment name and version: Chrome: Version 97.0.4692.99, Node: 16.13.1
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 10 & Windows 11

Reproducible demo

https://codesandbox.io/s/gifted-brahmagupta-juslb?file=/docs/intro.mdx

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionhelp wantedAsking for outside help and/or contributions to this particular issue or PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions