Skip to content

Commit 46e1895

Browse files
authored
fix(material/sort): error if signal is bound to disabled input (#31776)
The sort header clears a signal when the focused state of its descendants changes. This was causing a signal write error if a signal is bound to its `disabled` input, because changing the disabled state also ends up blurring the focused descendant. Fixes #31723.
1 parent 63e40d0 commit 46e1895

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/material/sort/sort-header.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI
188188
ngAfterViewInit() {
189189
// We use the focus monitor because we also want to style
190190
// things differently based on the focus origin.
191-
this._focusMonitor
192-
.monitor(this._elementRef, true)
193-
.subscribe(() => this._recentlyCleared.set(null));
191+
this._focusMonitor.monitor(this._elementRef, true).subscribe(() => {
192+
// We need the delay here, because we can trigger a signal write error if the header
193+
// has a signal bound to `disabled` which causes it to be blurred (see #31723.)
194+
Promise.resolve().then(() => this._recentlyCleared.set(null));
195+
});
194196
}
195197

196198
ngOnDestroy() {

0 commit comments

Comments
 (0)