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
[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
Open
NullVoxPopuli opened this issue
Feb 13, 2024
· 2 comments
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:
The text was updated successfully, but these errors were encountered:
NullVoxPopuli
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))
Feb 13, 2024
🐞 Describe the Bug
Repro
Code
😕 Actual Behavior
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),
🤔 Expected Behavior
Event listener is not removed.
🌍 Environment
➕ 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:
Repro/fix
The text was updated successfully, but these errors were encountered: