Skip to content

Reactivity: OnPush components change-detected even if nothing changed #51797

@pkozlowski-opensource

Description

@pkozlowski-opensource

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core framework

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions