Repository navigation
Let a nested ThemeProvider own the page's theme and follow mode changes - #142
Merged
brionmario merged 1 commit intoOct 28, 2026
Merged
Conversation
Every ThemeProvider writes its CSS variables and text direction onto the document root. An app that renders its own ThemeProvider inside the one ThunderIDProvider renders lost to it: the outer provider wrote its theme (the flow meta Design theme) last on load in React, and again whenever its theme changed in both React and Vue, so the SDK components showed a different theme from the app until something made the inner one write again. The innermost ThemeProvider now owns the document root. A nested provider claims it from the one above, which stops writing while the claim stands and writes its own theme again once the nested provider unmounts. `mode` also only seeded the color scheme, so a host app that drives it from its own color scheme toggle never saw the change. The color scheme now follows `mode` when it changes, in React and Vue. Signed-off-by: Brion <info@brionmario.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
ThaminduDilshan
approved these changes
Oct 28, 2026
6 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
An app that renders its own
ThemeProviderinside the oneThunderIDProviderrenders, to theme the SDK components with its own design system, loses to the outer one:modeonly seeds the color scheme, so a host app that drivesmodefrom its own color scheme toggle never sees the change.This showed up in the Admin Console (thunder-id/thunderid#6164). On a reload, the manage-* pages rendered in the application's orange, light Design theme inside the app's dark shell. The app currently works around it.
Approach
ThemeProviderowns the document root. Each provider shares a private "theme root" context (ThemeRootContextin React,THEME_ROOT_KEYin Vue).ThemeContextanduseThemedon't change.modewhen it changes.modeduring render when the prop changes, the pattern React recommends for adjusting state when a prop changes.mode, re-seeds the scheme and restarts thesystem/classdetection.Related Issues
Related PRs
ThemeProviderfor the manage-* pages. Its workaround can go once this is released.Checklist
packages/react/src/contexts/Theme/__tests__/ThemeProvider.nested.test.tsxandpackages/vue/src/__tests__/providers/ThemeProvider.nested.test.ts. Both cover keeping the nested theme when the outer theme changes, writing the outer theme again when the nested one unmounts, and following a change ofmode. They fail without the fix.breaking changelabel added.parity/prs-raisedorparity/prs-not-neededadded.parity/prs-not-needed: the bug comes from web providers sharing the DOM document root, which the iOS, Android and Flutter SDKs don't have. React and Vue are both fixed here; Next.js and Nuxt use them.Security checks