docs-bug(MatCellHarness): getColumnName returns the name, but altered
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
### 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Esamina la voce MatCellHarness.getColumnName() nella pagina dell’API Material table interessata, usando come contesto il metodo collegato CdkColumnDef._setNameInput e l’implementazione di cell harness. Aggiorna la documentazione per spiegare che i caratteri dei nomi delle colonne non compatibili con CSS, come i punti e le barre rovesciate, vengono sostituiti da trattini, e verifica che il comportamento dell’esempio sia rappresentato correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 48/100