Skip to content
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

bug(Table): filteredData of MatTableDataSource is not filled instantly on data change #21984

Closed
o-serhiichyk opened this issue Feb 23, 2021 · 2 comments · Fixed by #22058
Closed
Assignees
Labels
area: material/table help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@o-serhiichyk
Copy link

Reproduction

Steps to reproduce:

  1. Use Material 11.1.0 or above (up to 11.2.1).
  2. Create table with *ngIf that checks 'filteredData' property of table's MatTableDataSource.
  3. Clear 'data' property of MatTableDataSource.
  4. Set some 'data' to MatTableDataSource.

https://stackblitz.com/edit/components-issue-rgcbps?file=src/app/example-component.ts

Expected Behavior

Table is hidden and then displayed again.

Actual Behavior

Table is hidden and can not be displayed.

P.S. Everything works fine with Material 11.0.4 and below.

Environment

  • Angular: 11.2.1
  • CDK/Material: 11.2.1
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@o-serhiichyk o-serhiichyk added the needs triage This issue needs to be triaged by the team label Feb 23, 2021
@o-serhiichyk o-serhiichyk changed the title bug(Table): filteredData if MatTableDataSource is not filled instantly on data change bug(Table): filteredData of MatTableDataSource is not filled instantly on data change Feb 23, 2021
@jelbourn jelbourn added area: material/table help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Feb 23, 2021
@jelbourn
Copy link
Member

I confirmed that filteredData is indeed not being updated as I'd expect when data is updated in the linked StackBlitz

@crisbeto crisbeto self-assigned this Feb 28, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Feb 28, 2021
…onnected

The data source was changed in angular#21338 so that it unsubscribes while it's disconnected. The
problem is that the subscription has a side effect which updates `filteredData` as well.

These changes add some logic so that `filteredData` is updated even if the source is
disconnected.

Fixes angular#21984.
annieyw pushed a commit that referenced this issue Mar 9, 2021
…onnected (#22058)

The data source was changed in #21338 so that it unsubscribes while it's disconnected. The
problem is that the subscription has a side effect which updates `filteredData` as well.

These changes add some logic so that `filteredData` is updated even if the source is
disconnected.

Fixes #21984.
annieyw pushed a commit that referenced this issue Mar 9, 2021
…onnected (#22058)

The data source was changed in #21338 so that it unsubscribes while it's disconnected. The
problem is that the subscription has a side effect which updates `filteredData` as well.

These changes add some logic so that `filteredData` is updated even if the source is
disconnected.

Fixes #21984.

(cherry picked from commit 0093105)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/table help wanted The team would appreciate a PR from the community to address this issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants