Event listeners do not mark component as dirty when attached to ng-template
#39832
Labels
area: core
Issues related to the framework runtime
core: change detection
core: event listeners
hotlist: google
P2
The issue is important to a large percentage of users, with a workaround
Milestone
Affected Package
@angular/core
Is this a regression?
Yes, this works in View Engine.
Description
Events from a directive do not mark the parent component as dirty if the directive is on a non-rendered element (like an
ng-template
).🔬 Minimal Reproduction
https://stackblitz.com/edit/dir-events-on-template?file=src/app/app.component.ts
counter
directive on adiv
is marked dirty and refreshed.counter
on theng-template
is not updated.Original report: https://buganizer.corp.google.com/issues/173600938 (Overlay callbacks do not work with Ivy and OnPush)
We only call
wrapListener
when thetNode
isTNodeType.AnyRNode
:angular/packages/core/src/render3/instructions/listener.ts
Line 135 in 23c36a2
wrapListener
handles the logic for marking the view as dirty:angular/packages/core/src/render3/instructions/listener.ts
Lines 265 to 267 in 23c36a2
In View Engine, events always went through
dispatchEvent
, which handled the logic for marking the view as dirty:angular/packages/core/src/view/util.ts
Line 135 in d1ea1f4
The text was updated successfully, but these errors were encountered: