Skip to content

fix(table): data source not unsubscribing from render changes subscription #11394

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

Merged
Merged
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: 3 additions & 6 deletions src/lib/table/table-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MatTableDataSource<T> extends DataSource<T> {
* Subscription to the changes that should trigger an update to the table's rendered rows, such
* as filtering, sorting, pagination, or base data changes.
*/
_renderChangesSubscription: Subscription;
_renderChangesSubscription = Subscription.EMPTY;

/**
* The filtered set of data that has been matched by the filter string, or all the data if there
Expand Down Expand Up @@ -193,10 +193,6 @@ export class MatTableDataSource<T> extends DataSource<T> {
merge<PageEvent>(this._paginator.page, this._paginator.initialized) :
observableOf(null);

if (this._renderChangesSubscription) {
this._renderChangesSubscription.unsubscribe();
}

const dataStream = this._data;
// Watch for base data or filter changes to provide a filtered set of data.
const filteredData = combineLatest(dataStream, this._filter)
Expand All @@ -208,7 +204,8 @@ export class MatTableDataSource<T> extends DataSource<T> {
const paginatedData = combineLatest(orderedData, pageChange)
.pipe(map(([data]) => this._pageData(data)));
// Watched for paged data changes and send the result to the table to render.
paginatedData.subscribe(data => this._renderData.next(data));
this._renderChangesSubscription.unsubscribe();
this._renderChangesSubscription = paginatedData.subscribe(data => this._renderData.next(data));
}

/**
Expand Down