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

fix(v2): switch a toggle when system theme changed #2325

Merged
merged 2 commits into from
Feb 27, 2020

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Feb 26, 2020

Motivation

Resolve #2295.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Go to preview and in the settings of your OS change the system theme to the opposite (dark -> light and vice versa). Make sure the theme and the toggle state in navbar change appropriately on the preview website.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 added the pr: bug fix This PR fixes a bug in a past release. label Feb 26, 2020
@lex111 lex111 requested a review from yangshun February 26, 2020 00:47
@lex111 lex111 requested a review from wgao19 as a code owner February 26, 2020 00:47
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Feb 26, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Feb 26, 2020

Deploy preview for docusaurus-2 ready!

Built with commit 154c350

https://deploy-preview-2325--docusaurus-2.netlify.com

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm wondering why I'm not able to reproduce the original bug. The toggle switches well for me when I change my system theme.

@@ -61,6 +61,14 @@ const useTheme = () => {
}
}, [setTheme]);

useEffect(() => {
window
Copy link
Contributor

@yangshun yangshun Feb 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to check for disableDarkMode here, otherwise this runs on sites which still disable dark mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yangshun yangshun merged commit 37dff05 into master Feb 27, 2020
@yangshun yangshun deleted the fix-switch-theme-toggle branch February 27, 2020 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v2] Toggle theme component not reacting on change system theme
4 participants