docs-bug(MatCellHarness): getColumnName returns the name, but altered
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
### 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
Beitragsleitfaden
Rechercherichtung
Überprüfe den Eintrag zu MatCellHarness.getColumnName() auf der betroffenen Material table API-Seite und verwende die verknüpfte Methode CdkColumnDef._setNameInput sowie die Cell-Harness-Implementierung als Kontext. Aktualisiere die Dokumentation, um zu erklären, dass CSS-ungeeignete Zeichen in Spaltennamen, beispielsweise Punkte und umgekehrte Schrägstriche, durch Bindestriche ersetzt werden, und überprüfe, dass das Verhalten im Beispiel korrekt wiedergegeben wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 48/100