angular / angular/components

[CdkTable] consolidate data index in RowContext

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

説明

#### Bug, feature request, or proposal: proposal

#### What is the expected behavior?
Property pointing at the location of the row in the data source should be the same
for `CdkCellOutletMultiRowContext` and `CdkCellOutletRowContext`

#### What is the current behavior?
The property pointing at the location of the row in the data source is `index` in single-row template mode and `dataIndex` in multi-row tempalte mode.

#### What is the use-case or motivation for changing an existing behavior?

When working with the context, to figure out which property to use one will have to have
access to the table to query `multiTemplateDataRows` or check both properties which is >= 0.

The use case is for more complex tables, where a row model is needed and the context can be used as such.

This get's really annoying when working with templates... you need to explicitly request `index` and `dataIndex` in the template and query for the one in use... because 0 is a valid value doing `||` is not good as you might end up with `undefined`

I know that `RowContext` is public thus `index` and `dataIndex` must stay but it can be deprecated in the long run...

The code in the method `_updateRowIndexContext()` can become:

```ts
context.index = context.dataIndex = this._renderRows[renderIndex].dataIndex;
if (this.multiTemplateDataRows) {
context.renderIndex = renderIndex;
}
```
Instead of

```ts
if (this.multiTemplateDataRows) {
context.dataIndex = this._renderRows[renderIndex].dataIndex;
context.renderIndex = renderIndex;
} else {
context.index = this._renderRows[renderIndex].dataIndex;
}
```

And in future version deprecate one of the properties.

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

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

調査の方向性

まず `_updateRowIndexContext()` と issue で提案されている変更を読んでください。1 行テンプレートモードと複数行テンプレートモードで、`index`、`dataIndex`、`renderIndex` がどのように更新されるかを確認してください。両方の行コンテキスト型が同じデータソースインデックスを公開し、複数行モードでは引き続きレンダーインデックスが設定されていれば完了です。

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

評価

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

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

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