Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/material/sort/sort-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI
private _changeDetectorRef = inject(ChangeDetectorRef);
private _focusMonitor = inject(FocusMonitor);
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
private _ariaDescriber = inject(AriaDescriber, {optional: true});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a reason we didn't do this during the inject migration was that some apps were stubbing this out somehow in tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context, that makes sense. I'll close this.

private _ariaDescriber = inject(AriaDescriber);
private _renderChanges: Subscription | undefined;
protected _animationsDisabled = _animationsDisabled();

Expand Down Expand Up @@ -165,7 +165,7 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI
this._renderChanges?.unsubscribe();

if (this._sortButton) {
this._ariaDescriber?.removeDescription(this._sortButton, this._sortActionDescription);
this._ariaDescriber.removeDescription(this._sortButton, this._sortActionDescription);
}
}

Expand Down Expand Up @@ -226,9 +226,8 @@ export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewI
// nothing to update in the DOM.
if (this._sortButton) {
// removeDescription will no-op if there is no existing message.
// TODO(jelbourn): remove optional chaining when AriaDescriber is required.
this._ariaDescriber?.removeDescription(this._sortButton, this._sortActionDescription);
this._ariaDescriber?.describe(this._sortButton, newDescription);
this._ariaDescriber.removeDescription(this._sortButton, this._sortActionDescription);
this._ariaDescriber.describe(this._sortButton, newDescription);
}

this._sortActionDescription = newDescription;
Expand Down
Loading