angular / angular/components

bug(MatRadioButton): The `required` attribute is used on a radio button

Đang mở
#30,399 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Accessibility area: material/radio P2
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ả

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

When used in a radio group, the `required` attribute is used on a radio button. All the radio buttons under the group have `required` attributes. This attribute should not be used on individual radio buttons, because that creates illogical meta-data, which may be confusing for assistive technology users. It's not the individual controls that are required, it's the group as a whole that must have one choice made from it.

Code reference: https://source.corp.google.com/piper///depot/google3/third_party/javascript/angular_components/src/material/radio/radio.ts;l=250-257;bpv=1;bpt=1

### Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

### Expected Behavior

When a radio button is used inside a radio group, if the group is required and does not have a default selection, then add `aria-required="true"` to the wrapping element, not `aria-required/required` to the individual controls. We can leave it unchanged when a radio button is used outside a radio group, though I am unsure if that is a valid use case.

### Actual Behavior

The `required` attribute is applied to each radio button in a group.

### Environment

- Angular:
- CDK/Material:
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):

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 radio.ts, quanh các dòng được tham chiếu nơi thuộc tính required được áp dụng, và kiểm tra cách xử lý nhóm radio ở gần đó. Xác minh hành vi của các nút radio được nhóm và các nút radio độc lập, sau đó chạy các bài kiểm tra component radio liên quan; được coi là hoàn tất khi một nhóm required cung cấp aria-required trên wrapper của nó mà không áp dụng required hoặc aria-required cho từng control con.

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
accessibility, frontend
Loại issue
Lỗi
Độ 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
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.