mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Merge branch 'main' into nl/3210-fix-converted-federal-agency-none-check
This commit is contained in:
commit
b6ae8676c5
2 changed files with 10 additions and 2 deletions
|
@ -5,6 +5,5 @@
|
||||||
class="{{ uswds_input_class }}{% if classes %} {{ classes }}{% endif %}"
|
class="{{ uswds_input_class }}{% if classes %} {{ classes }}{% endif %}"
|
||||||
{% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}
|
{% if widget.value != None %}value="{{ widget.value|stringformat:'s' }}"{% endif %}
|
||||||
{% if aria_label %}aria-label="{{ aria_label }} {{ label }}"{% endif %}
|
{% if aria_label %}aria-label="{{ aria_label }} {{ label }}"{% endif %}
|
||||||
{% if sublabel_text %}aria-describedby="{{ widget.attrs.id }}__sublabel"{% endif %}
|
|
||||||
{% include "django/forms/widgets/attrs.html" %}
|
{% include "django/forms/widgets/attrs.html" %}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -57,6 +57,7 @@ def input_with_errors(context, field=None): # noqa: C901
|
||||||
legend_classes = []
|
legend_classes = []
|
||||||
group_classes = []
|
group_classes = []
|
||||||
aria_labels = []
|
aria_labels = []
|
||||||
|
sublabel_text = []
|
||||||
|
|
||||||
# this will be converted to an attribute string
|
# this will be converted to an attribute string
|
||||||
described_by = []
|
described_by = []
|
||||||
|
@ -103,6 +104,9 @@ def input_with_errors(context, field=None): # noqa: C901
|
||||||
elif key == "add_aria_label":
|
elif key == "add_aria_label":
|
||||||
aria_labels.append(value)
|
aria_labels.append(value)
|
||||||
|
|
||||||
|
elif key == "sublabel_text":
|
||||||
|
sublabel_text.append(value)
|
||||||
|
|
||||||
attrs["id"] = field.auto_id
|
attrs["id"] = field.auto_id
|
||||||
|
|
||||||
# do some work for various edge cases
|
# do some work for various edge cases
|
||||||
|
@ -152,11 +156,16 @@ def input_with_errors(context, field=None): # noqa: C901
|
||||||
if group_classes:
|
if group_classes:
|
||||||
context["group_classes"] = " ".join(group_classes)
|
context["group_classes"] = " ".join(group_classes)
|
||||||
|
|
||||||
|
# We handle sublabel_text here instead of directy in the template to avoid conflicts
|
||||||
|
if sublabel_text:
|
||||||
|
sublabel_div_id = f"{attrs['id']}__sublabel"
|
||||||
|
described_by.insert(0, sublabel_div_id)
|
||||||
|
|
||||||
if described_by:
|
if described_by:
|
||||||
# ensure we don't overwrite existing attribute value
|
# ensure we don't overwrite existing attribute value
|
||||||
if "aria-describedby" in attrs:
|
if "aria-describedby" in attrs:
|
||||||
described_by.append(attrs["aria-describedby"])
|
described_by.append(attrs["aria-describedby"])
|
||||||
attrs["aria_describedby"] = " ".join(described_by)
|
attrs["aria-describedby"] = " ".join(described_by)
|
||||||
|
|
||||||
if aria_labels:
|
if aria_labels:
|
||||||
context["aria_label"] = " ".join(aria_labels)
|
context["aria_label"] = " ".join(aria_labels)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue