-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Switching the theme from Light to Dark mode after the page reload works starting with the second attempt #22
Comments
@ollema I'm on |
@shimkiv can you share a reproduction repo? this does not seem to happen on my end from what I can tell from the video |
I'm observing the same issue on my end. Does not happen when reloading while dark mode is active. I copied the example from the docs and modified it to see if something with the component is wrong, but that is not the case. |
okay, so this preview is using the toggle seems to work fine for me.
what am I missing? Screen.Recording.2023-10-29.at.21.19.29.mov |
I observe the same behaviour as seen in your video (up to second 20 in my screen share) My system is also set to prefer light mode. The bug seems to be happening when:
When you are in light mode, and you press the toggle Screen.Recording.2023-10-29.at.21.32.32.mov |
thanks @fjlein for your additional information. I still can't seem to reproduce it. to double check, can you confirm that this is what you do:
I tried these four steps on both safari and chrome and it works for me. did you also try this with the link I sent above or only with your own apps? |
@ollema Yes, I can confirm that I followed those steps. Interestingly enough, I can not reproduce this bug in your provided link, only in my local app. |
can you confirm (maybe by clearing and reinstalling node_modules) that you are running 0.0.5? otherwise I am out of ideas if it works in the provided link and on my machine but not in your app |
Yes, I can confirm that this bug persists even after a clean reinstall of all modules including mode-watcher 0.0.5. :( |
FYI. <script lang="ts">
import { Button } from '$lib/components/ui/button'
import * as Tooltip from '$lib/components/ui/tooltip'
import { mode, toggleMode } from 'mode-watcher'
import { Moon, Sun } from 'radix-icons-svelte'
</script>
<div class="flex items-center space-x-2">
<Tooltip.Root>
<Tooltip.Trigger>
<div>
<Button on:click={toggleMode} variant="link" size="icon">
{#if $mode === 'light'}
<Sun
class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 text-foreground"
/>
{:else}
<Moon
class="h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 text-foreground"
/>
{/if}
</Button>
</div>
</Tooltip.Trigger>
<Tooltip.Content>
<p>Toggle theme color</p>
</Tooltip.Content>
</Tooltip.Root>
</div> And issue gone (also #21, which as stated should go to shadcn-svelte lib, was fixed). |
The If block fixes the issue for me as well! Thank you for the Update! Although I don't know the reason is for that. |
@fjlein, it looks like the |
https://www.shadcn-svelte.com is in use for the app.
Using documentation from here: https://www.shadcn-svelte.com/docs/dark-mode
Steps:
Actual results:
Expected results:
Issue recording: https://www.youtube.com/shorts/REMenzzOMAc
The text was updated successfully, but these errors were encountered: