-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[3.17.2] WillDestroy is called at a wrong time for components inside {{each}} #18855
Comments
I just ran into this same issue today where I had an array of ObjectProxy rendered with {{#each}}. Just like @seidelman notes, willRemove is called for the original items but isn't called for anything added to the list (e.g. willRemove(3) in his example. Great job @seidelman pinning this down! |
Looks like there's an extra updating Opcode that we missed which needs the destructor hooked up to it. I should be able to look in the next week or so, the fix should be similar to the one for #18797 |
Would this affect the |
Look like I have modified the Twiddle to demonstrate that as well. |
I am seeing an issue where willDestroy on a route I'm transitioning from fires after {{did-insert}} on the new route. As my components register with a service this means the new component registers with the service before the old component has unregistered. |
Failing test for emberjs/ember.js#18855 Fix destroyCount for last assert
i am facing the same (or maybe a similar?) issue that i have not been able to pin down or consistently reproduce. have you found a workaround for this? @pzuraq did you get a chance to take a look? |
I haven't had time just yet, but it's next on my todo list! Very much a high priority |
We've hit this issue, but with |
Bugfix submitted to the VM, going to be downstreaming soon |
Failing test for emberjs/ember.js#18855 Fix destroyCount for last assert
If a component is rendered in {{each}} block for items added to the list after initial rendering then
for those components
willDestroy()
is called only after{{each}}
block is removed.This issue is very similar to #18797 and it may be a result of the fix for that issue.
Why is this a problem
Our application uses Ember Leaflet to display a map with markers. Markers are displayed using
{{each}}
block with Ember Leaflet<Marker>
components inside. The component relies on life-cycle hooks to actually add and remove markers using leaflet.js library.Not calling
willDestroy
results in markers staying on a map after they were removed from a list.Reproduction Scenario
I have created an Ember Twiddle to illustrate the problem:
https://ember-twiddle.com/db073f2618c1f191f75ce249f89cb639
It creates a list with 2 elements and have buttons to add and remove elements. It removes whole
{{each}}
block if the list is empty. It also logs component construction andwillDestroy()
calls.If the Twiddle is configured for Ember 3.17.0, then those problematic
willDestroy()
are not called at all. Issue #18797If the Twiddle is configured for Ember 3.16.2, then those problematic
willDestroy()
are called as expected right after element removal from the listThe text was updated successfully, but these errors were encountered: