angular / angular/components

bug(material/table): Using `mat-text-column` within wrapped table doesn't work

Open
#27,040 1 comment 1 reaction 0 assignees View on GitHub
area: cdk/table P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Extending [wrapped table example](https://material.angular.io/components/table/examples#table-wrapped) from documentation with `mat-text-column` component causes whole table to break. The `MatTextColumn` component cannot find the material table to register to.

```


```

### Reproduction

See fork of the wrapped table example on Stackblitz: https://stackblitz.com/edit/3yrpgj-hxvvce

See console for errors. The table doesn't render properly until "symbol" column is removed from `displayedColumns` array.

### Expected Behavior

I would expect that using custom column definitions like the `MatTextColumn` would work with wrapped material table. However fixing this may turn out to be impossible due to how `ng-content` and componen initialization works.

### Actual Behavior

Adding the `mat-text-column` column within wrapped Material table throws an expection:

```
Error: Text column could not find a parent table for registration.
...
```

### Environment

- Angular: 16.0.0
- CDK/Material: 16.0.0
- Browser(s): Google Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu

Contributor guide

Open the contributing guide

Research direction

Start with the wrapped table example and its StackBlitz reproduction, then compare behavior with and without the mat-text-column element. Reproduce the registration error in Angular 16 and verify that the wrapped table renders correctly with MatTextColumn and the symbol column present.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.