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(theming): nested ColorSchemeProvider system color scheme handling #2000

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

jzempel
Copy link
Member

@jzempel jzempel commented Jan 16, 2025

Description

I ran into a gnarly error while attempting to retrofit ColorSchemeProvider on to the Garden website along with a new component page and embedded example. Due to React's useEffect cleanup logic the placement of the provider's mediaQuery listener was being unexpectedly removed from the embedded example. As a result, changing the system color scheme updated the website as expected, but was not cascading to the embedded example.

The solution was to move the useEffect out of the hook and into the ColorSchemeProvider itself. Doing so ensures mounting/unmounting (and associated listener add/removal) works as expected.

@coveralls
Copy link

coveralls commented Jan 16, 2025

Coverage Status

coverage: 95.536%. remained the same
when pulling 248b92f on jzempel/fix-colorschemeprovider
into 300f5f9 on main.

@jzempel jzempel merged commit ed8f785 into main Jan 16, 2025
8 checks passed
@jzempel jzempel deleted the jzempel/fix-colorschemeprovider branch January 16, 2025 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants