#35870: Allow customization of the blank option in select dropdowns
-------------------------------------+-------------------------------------
Reporter: Marijke Luttekes | Owner: Thibaud
Type: | Colas
Cleanup/optimization | Status: assigned
Component: Forms | Version: 5.0
Severity: Normal | Resolution:
Keywords: accessibility | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by jscholes):
I'm not sure about screen reader support levels for `aria-label` on
`<option>`. But I'd recommend against it for two other reasons:
Firstly, with mark-up like `<option aria-label="(select an
option)">-----</option>`, the accessible and visible labels would differ.
WCAG auditors would probably disagree on whether that represented a
failure of success criterion [
https://www.w3.org/WAI/WCAG22/Understanding
/label-in-name.html 2.5.3 (Label in Name)], because the line of dashes is
probably not a string that speech recognition users could speak out loud.
Nevertheless, the actual name would be invisible.
This leads onto a more important second point: If developers were to
override the default/placeholder text in code, Django would need to detect
that and remove the `aria-label`. Otherwise, setting e.g.
`blank_choice="None"` in Python would result in the HTML output `<option
aria-label="(select an option)">None</option>`. This would definitely be
a WCAG SC 2.5.3 failure, and a concrete accessibility bug because it would
affect meaning.
If `aria-label` was only updated to match the defined default, it would
arguably be an unnecessary use of ARIA at that point, with the potential
problems described in [
https://ericwbailey.website/published/aria-label-
is-a-code-smell/ aria-label is a code smell]. In short, I think `aria-
label` would introduce unwarranted complexity in this case.
As to the specific text of the default option: It doesn't have to be in
parentheses, e.g. MDN uses a string surrounded by dashes in some of their
examples. But it should begin with some sort of punctuation that users
are unlikely to type, to avoid it participating in the typeahead
functionality provided by the browser. E.g. `<option>Choose
one...</option>` would receive focus when users typed the letter C. That
may sometimes be what individual website developers want to happen, at
which point they should be overriding the default anyway.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35870#comment:10>