fix(theme-classic): do not switch color modes when printing#6490
fix(theme-classic): do not switch color modes when printing#6490
Conversation
|
✔️ [V2] 🔨 Explore the source changes: 221fadf 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61f38cb04635ba0008098588 😎 Browse the preview: https://deploy-preview-6490--docusaurus-2.netlify.app |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6490--docusaurus-2.netlify.app/ |
|
Size Change: +166 B (0%) Total Size: 755 kB
ℹ️ View Unchanged
|
slorber
left a comment
There was a problem hiding this comment.
LGTM 👍
What about always printing in light mode?
But probably in another PR
We don't render well dark mode anyway 🤷♂️
It's worth also testing on sites that only have a dark mode to be sure it works nicely in all cases. We might as well fix the rendering in dark mode
|
Yeah, if you test it, both in deploy preview and production, printing in dark mode results in terrible colors. I guess sites with only dark mode don't expect people to print them anyways, and even if we coerce to light mode, some colors are going to be terrible for them. I didn't figure out a nice way to update theme colors before printing. It seems as soon as you press print, the browser has already taken a snapshot of the page so further JS modifications are ignored. |
Motivation
Fix #6479.
We probably misunderstood the issue. The actual offending place is the media query listener. You can try with this minimal HTML:
When you press print, the PCS is coerced to light mode during printing, but then it was switched back to dark mode. This is because when printing, the browser wants the app to behave like it's in light mode. So the actual fix is to get rid of this fluctuation.
Problem is, which behavior do we actually prefer? Coercing the entire app to light mode when printing (and make the print result always look like light mode), or respect the current color mode? However, previously, printing in dark mode results in bad colors anyways (lighter theme color on a white background), so at least there isn't a regression with this change...
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Follow the repro steps in #6479; now when printing in dark mode, no changes are made.