angular / angular/components

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

Abierto
#30,399 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Accessibility area: material/radio P2
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en radio.ts, alrededor de las líneas referenciadas donde se aplica el atributo required, e inspecciona el manejo de los grupos de radio cercano. Verifica el comportamiento de los botones de radio agrupados e independientes y, después, ejecuta las pruebas relevantes del componente de radio; la tarea está terminada cuando un grupo required expone aria-required en su wrapper sin aplicar required ni aria-required a cada control hijo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
accessibility, frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.