angular / angular/components

bug(MatExpansionPanel): accordion property should be nullable

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

説明

#### Reproduction

https://stackblitz.com/edit/angular-jxhwbd

Steps to reproduce:
1. Try to access an accordion property from an expansion panel without accordion parent.

#### Expected Behavior
`accordion` should be `MatAccordionBase | null` to reflect its definition.

#### Actual Behavior
`accordion` is defined as:

https://github.com/angular/components/blob/3a6c16f0c04ce8784b0e015a71a889864f51a5f4/src/material/expansion/expansion-panel.ts#L134

... while it's optional in fact, as the `expansion-panel` can be used without `accordion` (btw the constructor parameter should also be marked with "?"):

https://github.com/angular/components/blob/3a6c16f0c04ce8784b0e015a71a889864f51a5f4/src/material/expansion/expansion-panel.ts#L151

--

##### PS: Note that there are other places where the constructor parameter is decorated with `@Optional`, but the property itself isn't. Maybe a good candidate for a rule to prevent this mistake.

#### Environment

Angular CLI: 10.0.3
Node: 13.7.0
OS: darwin x64

Angular: 10.0.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1000.3
@angular-devkit/build-angular 0.1000.3
@angular-devkit/build-optimizer 0.1000.3
@angular-devkit/build-webpack 0.1000.3
@angular-devkit/core 10.0.3
@angular-devkit/schematics 10.0.3
@angular/cdk 10.1.0
@angular/cli 10.0.3
@angular/flex-layout 10.0.0-beta.32
@angular/material 10.1.0
@ngtools/webpack 10.0.3
@schematics/angular 10.0.3
@schematics/update 0.1000.3
rxjs 6.6.0
typescript 3.9.7
webpack 4.43.0

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

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

調査の方向性

src/material/expansion/expansion-panel.ts の、参照されている accordion プロパティとコンストラクターの行から始め、StackBlitz の再現を確認して MatAccordion 親なしでの動作を検証します。完了条件は、コンストラクターパラメーターを含め、公開型が accordion の不在を正確に表し、関連する Angular Material のテストに合格することです。

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

評価

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

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

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