Projet

Général

Profil

0001-a11y-add-role-and-aria-labelledby-attributes-to-radi.patch

Frédéric Péters, 15 mars 2022 13:41

Télécharger (2,02 ko)

Voir les différences:

Subject: [PATCH] a11y: add role and aria-labelledby attributes to
 radio/checkboxes (#62750)

 wcs/qommon/form.py                            | 4 ++++
 wcs/qommon/templates/qommon/forms/widget.html | 2 ++
 2 files changed, 6 insertions(+)
wcs/qommon/form.py
212 212
class RadiobuttonsWidget(quixote.form.RadiobuttonsWidget):
213 213
    template_name = 'qommon/forms/widgets/radiobuttons.html'
214 214
    has_inside_labels = True
215
    a11y_labelledby = True
216
    a11y_role = 'group'
215 217
    content_extra_attributes = {'role': 'radiogroup'}
216 218

  
217 219
    def __init__(self, name, value=None, **kwargs):
......
1480 1482
class CheckboxesWidget(Widget):
1481 1483
    readonly = False
1482 1484
    template_name = 'qommon/forms/widgets/checkboxes.html'
1485
    a11y_labelledby = True
1486
    a11y_role = 'group'
1483 1487
    has_inside_labels = True
1484 1488

  
1485 1489
    def __init__(self, name, value=None, options=None, **kwargs):
wcs/qommon/templates/qommon/forms/widget.html
7 7
     {% if widget.field %}data-field-id="{{ widget.field.id }}"{% endif %}
8 8
     data-widget-name="{{ widget.name }}"
9 9
     {% if widget.div_id %}id="{{widget.div_id}}" data-valuecontainerid="form_{{widget.name}}"{% endif %}
10
     {% if widget.a11y_role %}role="{{ a11y_role }}"{% endif %}
11
     {% if widget.a11y_labelledby %}aria-labelledby="form_label_{{widget.name}}"{% endif %}
10 12
     {% for attr in widget.prefill_attributes %}
11 13
     data-{{attr}}="{{widget.prefill_attributes|get:attr}}"
12 14
     {% endfor %}
13
-