[FR] afterClosed for MatMenuTrigger and MatMenu
- 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ả
#### Bug, feature request, or proposal:
feature request
#### What is the expected behavior?
I want to be able to detect when a menu is completely closed (after the animation is done)
#### What is the current behavior?
there is a `menuClosed` event that is called when menu is about to be clsoed
#### What is the use-case or motivation for changing an existing behavior?
After menu item selected, I want to update a service the affects the displayed menu panel. Current menuClosed is too early, and it will cause the panel to reflect the change during the close animation.
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
angular 6.0.6, material 6.3.0
#### Is there anything else we should know?
workarounds:
1. ```js
onMenuClosed() {setTimeout(() => { /* doing stuff */ }, 500);}
1. ```js
@ViewChild(MatMenu) myMenu: MatMenu;
// ...
onMenuClosed() {
this.myMenu._animationDone
.pipe(filter(event => event.toState === 'void'), take(1))
.subscribe(() => {
/* doing stuff */
});
}
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách đọc vòng đời sự kiện của MatMenuTrigger và MatMenu, đặc biệt là sự kiện menuClosed hiện có và stream _animationDone được tham chiếu. Xác nhận thời điểm hoạt ảnh đóng hoàn tất và xác định hành vi afterClosed công khai cho cả hai component. Hoàn tất khi consumer có thể phản hồi sau khi menu đã đóng hoàn toàn mà không cần dựa vào timeout hoặc API private.
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
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100