-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Expressions inside {#if} blocks sometimes not correctly reactive to $derived properties of ES6 classes? #14846
Comments
very strange, seems like a bug. I wonder if it's only appearing in dev vs production? |
Hey @max-kamps, I have tried the code you provided and used $derived.by instead, so I can do some logging, along with the expression return.. The derivation re-evaluation has been triggered once the dependent state changed, that's fine. However, the conditional render did not react on the change. What I found even more interesting is, that when I added https://svelte.dev/playground/7ae10316bbaa413eb7a26c2d8a5a10b0?version=5.16.0 |
This probably relates to all the things I don't understand about Svelte's reactivity internals. My guess is that the value being read when the (future) rune |
btw,
looks like a check for
|
Describe the bug
In very specific circumstances (see reproduction playground), expressions inside of #if blocks referring to $derived properties of ES6 classes are not reactive.
Expected behavior: Clicking the "Set to 999" button always changes the "Associated Data" and "Associated Data inside the {#if}" rows to the same value, and changes the status line to green.
Actual behavior: Clicking the "Set to 999" button for the first time only changes the "Associated Data" row, while the "Associated Data inside the {#if}" row does not change and the status line remains red.
Only repeatedly clicking between "Set to null" and "Set to 999" eventually produces the expected result.
Apologies if this is user error, but the conditions for this occurring are so specific I have to believe it's a bug! 😄 Playground code was produced by painstakingly deleting code from my project until only a single file remained. Unfortunately I am not knowledgeable enough about Svelte internals to investigate this any further.
Reproduction
https://svelte.dev/playground/55439f2d8d8b47e386fafadac3b2c3ec?version=5.16.0
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: