Skip to content

bug(matSort): Writing to signals error when using [disabled] on mat-sort-header #31723

@nik2202

Description

@nik2202

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When a mat-sort-header uses [disabled] bound to a signal, sorting triggers NG0600: Writing to signals is not allowed while Angular renders the template. This happens because the signal is updated (disabled.set) during the sort event while Angular is still rendering.

Reproduction

StackBlitz link: https://stackblitz.com/edit/hgzpnems?file=src%2Fexample%2Fsort-overview-example.html,src%2Fexample%2Fsort-overview-example.ts
Steps to reproduce:

  1. Sort headers multiple times.
  2. Check console

Headers use a disabled state which is enabled during execution of the sorting

Expected Behavior

No error in the console. Hard to figure out where the issue occured.

Actual Behavior

With disabled option for sorting there is an internal error.

Image

Environment

  • Angular: 20.1.0
  • CDK/Material: 20.1.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows and macOs

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions