docs-bug(MatCellHarness): getColumnName returns the name, but altered
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 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
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Examinez l’entrée MatCellHarness.getColumnName() sur la page d’API Material table concernée, en utilisant comme contexte la méthode CdkColumnDef._setNameInput liée et l’implémentation de cell harness. Mettez à jour la documentation pour expliquer que les caractères de nom de colonne incompatibles avec CSS, tels que les points et les barres obliques inverses, sont remplacés par des tirets, et vérifiez que le comportement de l’exemple est correctement reflété.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 48/100