angular / angular/components

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

Abierto
#26,462 0 comentarios 0 reacciones 0 asignados Ver en GitHub
area: material/table docs P4
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

### 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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Revisa la entrada de MatCellHarness.getColumnName() en la página de la API de Material table afectada, usando como contexto el método vinculado CdkColumnDef._setNameInput y la implementación de cell harness. Actualiza la documentación para explicar que los caracteres no compatibles con CSS en los nombres de columna, como los puntos y las barras invertidas, se reemplazan por guiones, y verifica que el comportamiento del ejemplo se refleje correctamente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.