angular / angular/components

bug(MatExpansionPanel): accordion property should be nullable

Đang mở
#20,152 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: material/expansion P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu trong src/material/expansion/expansion-panel.ts tại thuộc tính accordion và các dòng constructor được tham chiếu, sau đó xem lại bản tái hiện trên StackBlitz để xác nhận hành vi khi không có phần tử cha MatAccordion. Hoàn tất nghĩa là kiểu công khai biểu diễn chính xác việc thiếu accordion, bao gồm cả tham số constructor, và các bài kiểm thử Angular Material liên quan đều vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.