-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Action called a second time when the order of items changes in a keyed each #2735
Comments
Here's what I found found about how this happens: In the function insert(block) {
/***/
block.m(node, next);
}
/***/
else if (!lookup.has(new_key) || will_move.has(new_key)) {
insert(new_block);
} In the compiled code of the component, I can see that the action calls are in the m(target, anchor) {
/***/
action_action = ctx.action.call(null, h2) || {};
}, I'm not sure about the way this should be fixed. Some questions:
|
Oh... This is tangentially related to #2446. Bindings, actions and event listeners currently do not have a set order. One way to fix this would require moving actions to The issue is that this would be a breaking change for actions since the dom tree would not be complete yet. Actions would be called on creation, so they'd need a way to be alerted of mounts ( The backward-compatible solution would be to move bindings and event listeners to |
This also seems to be related to #2711 — the issue seems to boil down to |
I am also experiencing this issue and created a simple repro case if that helps to fix it. |
Related #4491 |
Closing this, fixed by #4493 and included in v3.20.0 Thanks @tanhauhau! |
REPL link
In this example, after I click the button,
action()
is called a second time for nodec
, even though this is the same DOM element that has just been moved around/mounted again.destroy()
is not called.The text was updated successfully, but these errors were encountered: