Skip to content

feat(material/table): accept undefined sort and paginator #31269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions goldens/material/table/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ export class MatTableDataSource<T, P extends MatPaginator = MatPaginator> extend
_orderData(data: T[]): T[];
_pageData(data: T[]): T[];
get paginator(): P | null;
set paginator(paginator: P | null);
set paginator(paginator: P | null | undefined);
_renderChangesSubscription: Subscription | null;
get sort(): MatSort | null;
set sort(sort: MatSort | null);
set sort(sort: MatSort | null | undefined);
sortData: (data: T[], sort: MatSort) => T[];
sortingDataAccessor: (data: T, sortHeaderId: string) => string | number;
_updateChangeSubscription(): void;
Expand Down
12 changes: 8 additions & 4 deletions src/material/table/table-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ export class MatTableDataSource<T, P extends MatPaginator = MatPaginator> extend
return this._sort;
}

set sort(sort: MatSort | null) {
this._sort = sort;
set sort(sort: MatSort | null | undefined) {
// Treat undefined like the initial this._sort value.
// Note that the API can be changed in a breaking change to fix the cast.
this._sort = sort as MatSort | null;
this._updateChangeSubscription();
}

Expand All @@ -128,8 +130,10 @@ export class MatTableDataSource<T, P extends MatPaginator = MatPaginator> extend
return this._paginator;
}

set paginator(paginator: P | null) {
this._paginator = paginator;
set paginator(paginator: P | null | undefined) {
// Treat undefined like the initial this._paginator value.
// Note that the API can be changed in a breaking change to fix the cast.
this._paginator = paginator as P | null;
this._updateChangeSubscription();
}

Expand Down
Loading