-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Reactivity: OnPush components change-detected even if nothing changed #51797
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
In the current integration of signals into Angular the OnPush components are marked for check even if none of the underlying signals changed. This can happen with the longer reactivity chains where one of the computed signals is marked for re-computation but when recomputed it returns the same value. In this situation we should skip dirty-checking of such views.
Here is a minimal stackblitz demonstrating the situation: https://stackblitz.com/edit/stackblitz-starters-bxm5fu?file=src%2Fmain.ts
Given the above stackblitz, notice that the OnPush component is change detected even if non of the displayed values change. This is because components are marked for check in the signals notification phase, without any further verifications on the values produced by signals accessed in a template.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-bxm5fu?file=src%2Fmain.ts
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
No response
Anything else?
No response