You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Switching to 'Dark Mode' by itself when window.print() is called on Chrome #6479
I have read the console error message carefully (if applicable).
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.
The problem is that it forces you to print in dark mode, which sometimes messes things up because of incompatible colors. (The background stays white)
The hypothesis about empty local storage makes a lot of sense. I think we should try to preserve the color mode when printing though, if that's ever possible.
@slorber You can try on different browsers: on Chrome, pressing ⌘ + P immediately changes the color to dark, but on Safari, the page stays light until you close the print popup. Bit unexpected.
Activity
DogaGencerOSF commentedon Jan 27, 2022
here is my workaround for now if it helps with the development process: https://gist.github.com/DogaGencerOSF/2b70373a8ee10727e5e5ec2a881f5646
Josh-Cena commentedon Jan 27, 2022
I'm still totally clueless whether we are doing something wrong or if this is browser behavior... Looks like Safari has the same behavior as well
slorber commentedon Jan 27, 2022
I guess it's like opening the site in a new browser session, with localStorage empty 🤷♂️
Maybe we could add an option, or always force light mode in print?
Is there a use case for printing in dark mode?
Josh-Cena commentedon Jan 27, 2022
The problem is that it forces you to print in dark mode, which sometimes messes things up because of incompatible colors. (The background stays white)
The hypothesis about empty local storage makes a lot of sense. I think we should try to preserve the color mode when printing though, if that's ever possible.
@slorber You can try on different browsers: on Chrome, pressing ⌘ + P immediately changes the color to dark, but on Safari, the page stays light until you close the print popup. Bit unexpected.