angular / angular/components

feat(autocomplete): allow configuring requireSelection blur behavior without resetting value to null

Đang mở
#32,953 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
area: material/autocomplete feature P3
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

Please add a configurable option such as preserving the previous selection on blur, so that `requireSelection` does not have to emit `null` unless the application explicitly wants that behavior.

Related issues:
- #27767: `requireSelection` clears input on blur
- #28590: `[requireSelection]="true"` breaks `valueChanges`

### Use Case

In our case, we manually restore the previous selected value when Angular resets the control to `null`.

That workaround causes multiple `valueChanges` emissions for a single user interaction: first `null`, then the previously selected value after we restore it. This is noisy, annoying to handle, and not reliably distinguishable from a real clear action triggered by the user.

We want to detect an actual clear action separately from the case where the user only focuses the input, opens the autocomplete panel, and then blurs without selecting a new option. A configurable behavior here would prevent unnecessary state changes and extra reactive form events.

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

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

Hướng nghiên cứu

Start by tracing the Angular autocomplete requireSelection blur behavior and how it emits valueChanges when the panel closes. Read related issues #27767 and #28590 for existing constraints. Done means applications can configure whether blur preserves the previous selection or emits null, while an explicit clear remains distinguishable.

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
55/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.