-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Updating a signal or calling markForCheck
should schedule change detection. Bound listener callbacks as well as creating, inserting, or attaching a view should also schedule change detection. This will be the case for zoneless applications but should also apply to zone-based applications when these actions happen outside the Angular zone. It is a confusing implementation detail that these APIs do not schedule change detection even though they specifically indicate that change detection should run.
This would address a lot of confusion including, but almost certainly not limited to, my quick search finding the following issues:
- Change detection not triggered when Signal.set() called from Observable subscription #53841
- Change Detection wont run if a singal's value gets updated from within a
ResizeObserver
#52610 - Setting/updating a signal must be done in NgZone(?) #53566
- Signals don't trigger change detection using native async/await (ES2017+) #52940
- @defer: placeholder and loading blocks are not removed by BaseAnimationRenderer (TransitionAnimationEngine) #51970
- Async pipe breaks on specific project structure #51768
- Zoneless: stream created using toObservable rxjs-interop emits only initial value #50702
- Signals without ngZone not yet working? #50259
- signal does not update UI when set in a ResizeObserver callback #50266
- Updating a signal outside zone.js triggers no effect #50160
- Signal doesn't set without setTimeout in observable v16.0.0-rc.2 #49940
- RouterTestingHarness should trigger change detection after any navigation #49398
- ResizeObserver should be patched automatically by zone.js #48890
- Change detection should run automatically after router navigation in unit tests #48608
- ResizeObserver callback is not running in zone #45105
- Why the change detection is not fire with fromEvent and runOutsideAngular? #42241
- Guard with observable causing the entire app to misbehave [Minimal stackblitz included] #41553
- Zoneless async router guards break change detection #37223
- Change detection not triggering for template event handler #37062
- Observable updates aren't reflected in templates if their change origin is not the application itself #35579
- ResizeObserver (and MutationObserver) not patched by zone.js #31695
- feature(router): warn if navigation triggered outside Angular zone #24728
- Change detection is not working with router navigation #23697
- Change detection is not updating the view when you mark for check. #19814
- Async pipe doesn't read (or update) ngrx/store observables when triggered from specific places (Google API's callbacks) #13957
- [Bug] Animation not triggered on window.resize #11565
along with the ones linked from there: #15770, #15946, #18254, #19731, #20112, #22472, #23697, #24727, #47236 (navigations create views so it should always schedule change detection, even if triggered outside the zone)
In addition to the above, there's plenty of code around that is forced to try dealing with zones when it really shouldn't be necessary because one of the above APIs are used.
- fix(core): deferred blocks not removing content immediately when animations are enabled #51971 (defer blocks attach views so they should schedule change detection without the listeners needing to run inside the zone)
- https://github.com/angular/components/blob/1fe1f69303780c11c07ff84313f5fdc10440d55b/src/material/snack-bar/snack-bar-container.ts#L203-L210 (
markForCheck
is called so you should not also have to usengZone.run
to ensure change detection is scheduled)
There is certainly a question of whether this would make things more unpredictable. For example, would this cause components created outside the zone to act even more unpredictably where some things cause change detection and others don't (because they were created outside the zone).