fix: use resolvedTheme for accurate theme management #105
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.
Currently, when
enableSystem
is set,scira/app/providers.tsx
Lines 19 to 24 in 83d73d7
the theme parameter returns
system
instead oflight
ordark
. This causes an issue where new users (those without a saved theme preference in localStorage) cannot change the theme on their first click. To reproduce the issue, clear cookies and try toggling the theme.theme.mp4
As stated in the next-themes docs,
when
enableSystem
istrue
and the active theme issystem
, theme remainssystem
while resolvedTheme returns whether the system preference is resolved todark
orlight
.The new implementation is similar to the one done by shadcn:
https://github.com/shadcn-ui/ui/blob/12d4cf2ab0caefec5d6232e6c32220a8e62d73c4/apps/v4/components/mode-toggle.tsx#L10