angular / angular/components

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

Ouverte
#30,399 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Accessibility area: material/radio P2
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez dans radio.ts, autour des lignes référencées où l’attribut required est appliqué, et examinez la gestion des groupes de boutons radio à proximité. Vérifiez le comportement des boutons radio groupés et autonomes, puis exécutez les tests pertinents du composant radio ; c’est terminé lorsqu’un groupe required expose aria-required sur son wrapper sans appliquer required ni aria-required à chaque contrôle enfant.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
accessibility, frontend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.