-
-
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
Bug involving transition, value binding and "bind:this" #6389
Comments
It's a bit difficult to see your exact use-case here, I might suggest that you could pair down the REPL into an even simpler format. What I did was I modified your switch method so that it switched between the two components rather than always switching to input, and the binding is then never undefined, and is in fact always bound to the correct component (the visible one). If this works for you, I would suggest that you are able to do whatever you need to here, and this isn't an issue. If you think there is still an issue, I think a simpler REPL would help us understand and fix it. |
Thanks for taking a look into this. The REPL indeed doesn't represent the actual use case all that well, which looks like this: The app has an always visible sidebar, and a main area that different components are slotted into. One of them contains a form, and whenever you switch away from it, I need to call a method to see if its content was changed. So I keep a reference to the current component using I don't know how to simplify the REPL even further while keeping all three conditions that seem to be necessary to reproduce in there (1: 'bind:this`, 2: transition, 3: interaction with an input field inside the component).
I'd be grateful to see the modification you made. With it, does the reference stay not Also, I just noticed that if you click the button twice, |
Met same issue here~ |
Fixed in Svelte 5 |
Is this about svelte@next? This project is currently in a pre-release stage and breaking changes may occur at any time. Please do not post any kind of bug reports or questions on GitHub about it.
No, it's about version 3.38.2
Describe the bug
The reference to a child component is set to
null
after it is transitioned out, replaced by another one, and you interact with that new child. Here is a REPL to try it out. The text at the very bottom indicates whetherchildNode
(which is bound to a component viabind:this
) isnull
or not. The steps to reproduce are:I can reliably reproduce it in Firefox 89 and Safari 14.1.1, both on macOS 10.14.6
Expected behavior
The node reference should always point to one of the components, and never be
null
Severity
Moderately severe, since there is a workaround, which is not to use transitions anywhere. I'm building an interface that has a static left column and different components for the main area. Having them fade into each other (as well as some animations inside them) is at the very least nicer than abrupt changes, so I would like to keep the transitions in place.
One of the components stores user input that I would like to notify the user about if they didn't save their changes. I do that by calling a function exposed via
export const function
before the component switch happens. At that time, the child reference (itsbind:this
value) should always point to the component. Instead, because of this bug, it turns tonull
sometimes and then the UI breaks because I'm trying to call a method onnull
:The text was updated successfully, but these errors were encountered: