angular / angular/components

docs-bug(MatCellHarness): getColumnName returns the name, but altered

Open
#26,462 0 comments 0 reactions 0 assignees View on GitHub
area: material/table docs P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Documentation Feedback

The description of `MatCellHarness.getColumnName()` states that it

> Gets the name of the column that the cell belongs to.

What it DOESN'T say is that if the column name has any symbols in it like dots or backslashes or anything that the [_setNameInput method in CdkColumnDef](https://github.com/angular/components/blob/623b0c94e90f83ba1a91d93137ebad6622e12bdd/src/cdk/table/cell.ts#L139) would consider not CSS friendly, the harness will instead return that column's name with all of the offending characters replaced with dashes

**Example:**

Let's say that I've defined row template as [per point 3 in MatTable's Getting Started](https://material.angular.io/components/table/overview#3-define-the-row-templates) section, and one of the columns is called _"bar.tar"_

`columnsToDisplay = ['foo', 'bar.tar'];`

Later on I'm writing tests and using test harnesses to get a list of that table's columns

```
// cells is of type MatCellHarness[]
const columnNames = await parallel(() => cells.map(cell => cell.getColumnName()));
// columnNames is ['foo', 'bar-tar']
```

As I understand, it's because the cell harness uses the [cell's own CSS class](https://github.com/angular/components/blob/31a754c90405ac3a21858cdd038d56aa7375fabc/src/material/table/testing/cell-harness.ts#L23) to deduct its column's name, which is fair enough, but I do strongly think that this behaviour should be documented

### Affected documentation page

https://material.angular.io/components/table/api#MatCellHarness

Contributor guide

Open the contributing guide

Research direction

Review the MatCellHarness.getColumnName() entry on the affected Material table API page, using the linked CdkColumnDef._setNameInput method and cell harness implementation for context. Update the documentation to explain that CSS-unfriendly column-name characters, such as dots and backslashes, are replaced with dashes, and verify the example behavior is accurately reflected.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.