You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] DX: due to destruction happening "at any time" / asynchronously, we cannot ergonomically use a conditional on modifier (aka conditional on modifiers are not possible if the condition goes from true to true)) #20647
teardown happens after setup, but because the same reference to the function that handles the 'click' event is passed, the event listener is removed.
when clicking the double button (can only click me when even),
this.isEven is dirtied twice, even though the value remains the same
when isEven is dirtied, the modifier destroys itself and re-sets itself up
🤔 Expected Behavior
Event listener is not removed.
🌍 Environment
Ember: - 5.5
➕ Additional Context
As a work-around, or maybe ... the solution? we need to create a new reference to the function every time the condition changes so that each addEventListener / removeEventListener pair has a unique reference to the function to handle the event.
atm, I'm trying to figure out how to do that tho
here is a solve:
had to do a custom on modifier that always made its own local ref of the passed function:
changed the title [-][Bug] DX: due to destruction happening "at any time" / asynchronously, we cannot ergonomically use a conditional `on` modifier (aka conditional `on` modifiers are not possible if the condition goes from false to true))[/-][+][Bug] DX: due to destruction happening "at any time" / asynchronously, we cannot ergonomically use a conditional `on` modifier (aka conditional `on` modifiers are not possible if the condition goes from true to true))[/+]on Feb 13, 2024
I think this is actually fixed -- I can't reproduce my original issue report (and I think the on modifier is currently using the recommended fix anyway)
Activity
[-][Bug] DX: due to destruction happening "at any time" / asynchronously, we cannot ergonomically use a conditional `on` modifier (aka conditional `on` modifiers are not possible if the condition goes from false to true))[/-][+][Bug] DX: due to destruction happening "at any time" / asynchronously, we cannot ergonomically use a conditional `on` modifier (aka conditional `on` modifiers are not possible if the condition goes from true to true))[/+]NullVoxPopuli commentedon Feb 13, 2024
Candidates in case this is regression:
Add test for conditional on to try to reproduce emberjs/ember.js#20647
NullVoxPopuli commentedon Feb 13, 2024
Gonna try to pair with @chancancode on some of this.
I'm getting hung up on
@glimmer-workspaces made up testing environment 😅NullVoxPopuli commentedon May 6, 2026
I think this is actually fixed -- I can't reproduce my original issue report (and I think the on modifier is currently using the recommended fix anyway)