feat(dialog): Support async `MatDialogConfig.closePredicate`
- 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ả
### Feature Description
For a long time we wanted to be able to cancel dialog closure, in #14292. It was solved via a new option, `closePredicate`, in #14292. But that new option does not support async code. And so we cannot, for example, ask user for the confirmation to close the dialog (via a second dialog), nor do XHR to verify things on server-side.
This kind of use case was already mentioned by @teolag in https://github.com/angular/components/issues/14292#issuecomment-2828734239, but that specific part of the message was left unanswered. And @Nakira had to come up with a custom solution to solve this in https://github.com/angular/components/issues/14292#issuecomment-2907749489
### Use Case
I want the dialog closure to wait until I know whether it can be closed. Possibly via asking the user that he is OK to lose all the data he just input in the dialog, like so:
```ts
this.matDialog.open(MyDialogComponent, {
closePredicate: async () => await askUserIfReallySure(),
});
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với hành vi hiện có của MatDialogConfig.closePredicate và luồng đóng dialog; issue cung cấp tùy chọn công khai và một ví dụ sử dụng bất đồng bộ. Theo dõi cách kết quả của predicate được xử lý, sau đó xác minh rằng việc đóng dialog chờ xác nhận bất đồng bộ và vẫn hỗ trợ hủy.
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 52/100