angular / angular/components

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

オープン
#26,462 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
area: material/table docs P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

影響を受ける Material table API ページの MatCellHarness.getColumnName() の項目を、リンクされている CdkColumnDef._setNameInput メソッドと cell harness の実装をコンテキストとして確認してください。列名に含まれる CSS で使用できない文字(ドットやバックスラッシュなど)がダッシュに置き換えられることを説明するようドキュメントを更新し、例の動作が正確に反映されていることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。