Page MenuHomePhabricator

Add role="search" to search forms
Open, Needs TriagePublic

Description

Forms with type=search, type=search2, and type=fulltext are used for search which corresponds to the "search" ARIA role (see MDN). The suggestion is to add role="search" to the form element for them.

Context
Of all things ARIA, InputBox currently supports only the aria-label attribute on the <input> element added in T242354:

image.png (200×1 px, 26 KB)

Open questions
A possible concern here is that when several elements on the page share the same landmark role (like search or form), it is advised that they have different aria-labels. Currently the main MediaWiki search functionality has no aria-label parameter (I checked Vector 2022, Vector, Monobook), and InputBox only supports aria-labels on inputs, not the whole form. But I'm not sure that the users of assistive technologies really need any hint that the first search landmark on MediaWiki sites is the sitewide search. According to this note on MDN,

image.png (159×875 px, 28 KB)

labels can be announced by screen readers together with the role. So does adding "Sitewide" to "search" really add value here?.. Another question is whether aria-label on forms created by InputBox is required.

Event Timeline

On second thought, forms can have introductory text like which lies out of the input box markup:

<div style="float: right;">
Wanna search for THIS? Do it in this form:
<inputbox>
...
</inputbox>
</div>

In this case the text "Wanna search for THIS? Do it in this form" gets placed outside of the landmark and, I presume, becomes inaccessible for screen readers? Only type=search2 supports labels inside the form:

image.png (182×1 px, 17 KB)

If we can't know automatically where the introductory text is, maybe we shouldn't use role at all, leaving it to the editor. But it would then make sense to explicitly state it in the documentation of the extension.