bug(MatExpansionPanel): accordion property should be nullable
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
#### 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
Beitragsleitfaden
Rechercherichtung
Beginne in src/material/expansion/expansion-panel.ts bei der referenzierten accordion-Eigenschaft und den Konstruktorzeilen und überprüfe anschließend die StackBlitz-Reproduktion, um das Verhalten ohne ein MatAccordion-übergeordnetes Element zu bestätigen. Erledigt ist die Aufgabe, wenn die öffentliche Typisierung das fehlende accordion einschließlich des Konstruktorparameters korrekt darstellt und die relevanten Angular Material-Tests bestehen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100