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): Angular 9: caching column definitions breaks nesting tables #18768

Assignees
Labels
P2 The issue is important to a large percentage of users, with a workaround

Comments

@dtarjeft
Copy link

dtarjeft commented Mar 9, 2020

Reproduction

Steps to reproduce:

  1. Open this StackBlitz from this StackOverflow answer regarding nested material tables using Angular 8.
  2. Observe that clicking on table rows causes the table to expand/collapse and show nested data.
  3. Upgrade Angular to 9.0.5. For convenience, here's a StackBlitz with this completed.

Expected Behavior

Nested material tables in each mat-row with those columns defined, opening and closing as intended. No errors.

Actual Behavior

Expanding a row works the first time, then fails, leaving the table in a bad state throwing errors to the effect of Duplicate column definition name provided - the expansion/collapse functionality completely stops working at this point.

One can work around this by creating a dummy component who's sole purpose is to pass the data to another instance of mat-table - I've shown this in a fork of the Angular 9 StackBlitz. Note: I didn't preserve the filters from the original StackBlitz, as that was not part of the functionality in question.

Environment

  • Angular: 9.0.5
  • CDK/Material: 9.1.1
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@dtarjeft dtarjeft added the needs triage This issue needs to be triaged by the team label Mar 9, 2020
@dtarjeft dtarjeft changed the title bug([mat-table]): Angular 9: caching column definitions breaks nesting tables bug(Table): Angular 9: caching column definitions breaks nesting tables Mar 9, 2020
@FredyValstrauss
Copy link

I'm facing this exact same issue with Angular 9 and Angular Material 9.1.0. Please help!

@dtarjeft
Copy link
Author

@FredyValstrauss This component should work around the issue for the time being, though I trust the Angular team will be able to come up with a better solution.

@FredyValstrauss
Copy link

Hi @dtarjeft, your work aroud worked wonderful in my case. I only modified the template to use templateURL and use a separate html file, but it works just fine. As you said, this is a work around and Angular team should release a better and much simpler solution. Thanks again for the work around!

@crisbeto crisbeto self-assigned this Mar 15, 2020
@crisbeto crisbeto added has pr P2 The issue is important to a large percentage of users, with a workaround and removed needs triage This issue needs to be triaged by the team labels Mar 15, 2020
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 15, 2020
Previously we used to support nesting tables, but in v9 we had to make some changes in order to handle all cases in Ivy. As a result, nesting was broken due to parent tables picking up the cell definitions of their children. These changes add some logic to account for tables being nested.

Fixes angular#18768.
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 15, 2020
Previously we used to support nesting tables, but in v9 we had to make some changes in order to handle all cases in Ivy. As a result, nesting was broken due to parent tables picking up the cell definitions of their children. These changes add some logic to account for tables being nested.

Fixes angular#18768.
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 16, 2020
Previously we used to support nesting tables, but in v9 we had to make some changes in order to handle all cases in Ivy. As a result, nesting was broken due to parent tables picking up the cell definitions of their children. These changes add some logic to account for tables being nested.

Fixes angular#18768.
mmalerba pushed a commit that referenced this issue Mar 21, 2020
Previously we used to support nesting tables, but in v9 we had to make some changes in order to handle all cases in Ivy. As a result, nesting was broken due to parent tables picking up the cell definitions of their children. These changes add some logic to account for tables being nested.

Fixes #18768.
@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 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.