mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #34705 -- Reallowed BoundField.as_widget()'s attrs argument to set aria-describedby.
Regression in 966ecdd482.
This commit is contained in:
committed by
Mariusz Felisiak
parent
e5e9699e0f
commit
3f73df44f2
@@ -287,12 +287,15 @@ class BoundField(RenderableFieldMixin):
|
||||
attrs["required"] = True
|
||||
if self.field.disabled:
|
||||
attrs["disabled"] = True
|
||||
# If a custom aria-describedby attribute is given and help_text is
|
||||
# used, the custom aria-described by is preserved so user can set the
|
||||
# desired order.
|
||||
if custom_aria_described_by_id := widget.attrs.get("aria-describedby"):
|
||||
attrs["aria-describedby"] = custom_aria_described_by_id
|
||||
elif self.field.help_text and self.id_for_label:
|
||||
# If a custom aria-describedby attribute is given (either via the attrs
|
||||
# argument or widget.attrs) and help_text is used, the custom
|
||||
# aria-described by is preserved so user can set the desired order.
|
||||
if (
|
||||
not attrs.get("aria-describedby")
|
||||
and not widget.attrs.get("aria-describedby")
|
||||
and self.field.help_text
|
||||
and self.id_for_label
|
||||
):
|
||||
attrs["aria-describedby"] = f"{self.id_for_label}_helptext"
|
||||
return attrs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user