mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #32819 -- Avoided adding 'aria-describedby' to hidden inputs.
Hidden elements are not visible for both accessibility tools and browsers presentation layer. This change therefore only reduces the size of the generated HTML.
This commit is contained in:
parent
85c154da2f
commit
c187f5f924
@ -298,6 +298,7 @@ class BoundField(RenderableFieldMixin):
|
||||
and self.field.help_text
|
||||
and not self.use_fieldset
|
||||
and self.auto_id
|
||||
and not self.is_hidden
|
||||
):
|
||||
attrs["aria-describedby"] = f"{self.auto_id}_helptext"
|
||||
return attrs
|
||||
|
@ -2136,6 +2136,15 @@ class FormsTestCase(SimpleTestCase):
|
||||
p.as_p(), '<input type="hidden" name="foo"><input type="hidden" name="bar">'
|
||||
)
|
||||
|
||||
def test_hidden_widget_does_not_have_aria_describedby(self):
|
||||
class TestForm(Form):
|
||||
hidden_text = CharField(widget=HiddenInput, help_text="Help Text")
|
||||
|
||||
f = TestForm()
|
||||
self.assertEqual(
|
||||
str(f), '<input type="hidden" name="hidden_text" id="id_hidden_text">'
|
||||
)
|
||||
|
||||
def test_field_order(self):
|
||||
# A Form's fields are displayed in the same order in which they were defined.
|
||||
class TestForm(Form):
|
||||
|
Loading…
Reference in New Issue
Block a user