Skip to content

Commit 9313f18

Browse files
crisbetommalerba
authored andcommitted
fix(table): data source not unsubscribing from render changes subscription (#11394)
Currently the data source has a `_renderChangesSubscription` which doesn't do anything, because it's never being assigned to. These changes assign the proper subscription to it. Fixes #11382.
1 parent acc24c4 commit 9313f18

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/lib/table/table-data-source.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class MatTableDataSource<T> extends DataSource<T> {
4343
* Subscription to the changes that should trigger an update to the table's rendered rows, such
4444
* as filtering, sorting, pagination, or base data changes.
4545
*/
46-
_renderChangesSubscription: Subscription;
46+
_renderChangesSubscription = Subscription.EMPTY;
4747

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

196-
if (this._renderChangesSubscription) {
197-
this._renderChangesSubscription.unsubscribe();
198-
}
199-
200196
const dataStream = this._data;
201197
// Watch for base data or filter changes to provide a filtered set of data.
202198
const filteredData = combineLatest(dataStream, this._filter)
@@ -208,7 +204,8 @@ export class MatTableDataSource<T> extends DataSource<T> {
208204
const paginatedData = combineLatest(orderedData, pageChange)
209205
.pipe(map(([data]) => this._pageData(data)));
210206
// Watched for paged data changes and send the result to the table to render.
211-
paginatedData.subscribe(data => this._renderData.next(data));
207+
this._renderChangesSubscription.unsubscribe();
208+
this._renderChangesSubscription = paginatedData.subscribe(data => this._renderData.next(data));
212209
}
213210

214211
/**

0 commit comments

Comments
 (0)