Skip to content

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

Open
@karlkibus

Description

@karlkibus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: material/tabledocsThis issue is related to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions