Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark theme blinks on refresh #1995

Closed
lex111 opened this issue Nov 14, 2019 · 3 comments · Fixed by #2069
Closed

Dark theme blinks on refresh #1995

lex111 opened this issue Nov 14, 2019 · 3 comments · Fixed by #2069
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@lex111
Copy link
Contributor

lex111 commented Nov 14, 2019

🐛 Bug Report

When loading a page with dark mode turned on, a light theme is visible for a while before the previously selected dark theme is applied.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Select dark theme in navbar
  2. Reload (F5 or Ctrl + R) any page

Expected behavior

A dark theme should be shown right away

Actual Behavior

For a second or so, a "regular" light theme is showed, and only then a dark theme:

AwesomeScreenshot-2019-11-14-1573758888334

@lex111 lex111 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers v2 labels Nov 14, 2019
@lex111 lex111 changed the title White flash between page loads White flash between page loads when in dark mode Nov 14, 2019
@lex111 lex111 changed the title White flash between page loads when in dark mode Dark theme blinks on refresh Nov 14, 2019
@yangshun
Copy link
Contributor

Yeah we're aware of this issue. It's because the theme is only applied after page load, that's why we see the flash. It's a little annoying but possible to fix - gatsbyjs.org doesn't have this issue.

@lex111
Copy link
Contributor Author

lex111 commented Nov 14, 2019

A good example where there is no such issue - https://overreacted.io/ (yeah, powered by Gatsby).

@endiliey
Copy link
Contributor

Try reading this https://github.com/donavon/use-dark-mode/blob/develop/README.md#that-flash

To fix this, we need a setbody hooks to inject script into html body. So that it wont wait till React load to actually enter dark mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@yangshun @lex111 @endiliey and others