-
-
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
#if not disposing child element when going from true => false (occurs intermittently) #4346
Comments
Just a guess, but if you use |
Yeah by design |
Here's a repl using https://svelte.dev/repl/ef732af8391246dc878f5b878199aeb1?version=3.18.1 The bug appears if you flip through one end of the carousel to the other and click on the background. Here's an example: https://streamable.com/riew9. isOpen is false, yet the Relevant code: https://github.com/sjafferi/svelte-images/blob/svelte-comp/src/Images/Modal.svelte#L77 |
The issue seemed to go away after cleaning up the component structure. Relevant commit: sjafferi/svelte-images@64458b5 |
Description
I'm building an image viewer in svelte and have an issue that's stumped me. Every once in a while, when an {#if} block switches from truthy to falsy, the element inside is not disposed in the html.
This is occurring inside a modal component that sets it's component to null when it closes. Works 90% of the time, but every once in a while, the element stays on the page despite it's condition being falsy.
This is the relevant code:
Can be found here: https://github.com/sjafferi/svelte-images/blob/master/src/Images/Modal.svelte#L97
The repo is: https://github.com/sjafferi/svelte-images
Can be run using yarn && yarn dev
Note: bug is intermittent and occurs when opening and closing the image carousel.
Here's a video of the bug: https://streamable.com/2musq
Observe that I'm logging
Component
on the dom, and you can see that it's null once the bug occurs but the<div class="bg" ...>
element is still present on the page. Let me know if you need clarification.The text was updated successfully, but these errors were encountered: