w3c / html-aria

ARIA in HTML
https://w3c.github.io/html-aria/
Other
181 stars 49 forks source link

Review allowed roles for `button` #375

Closed ZoeBijl closed 2 years ago

ZoeBijl commented 2 years ago

With the introduction of a select only combobox (no text input), would it make sense to allow role=combobox on <button>?

<button
    aria-label="Tag"
    role="combobox"
    aria-activedescendant="selected_option"
    aria-autocomplete="list"
    aria-controls="owned_listbox"
    aria-expanded="true"
    aria-haspopup="listbox"
    type="button"
>
    Zoom
</button>
<ul role="listbox" id="owned_listbox">
    <li role="option">Zebra</li>
    <li role="option" id="selected_option">Zoom</li>
</ul>
scottaohara commented 2 years ago

Been mulling this over for awhile, and did some testing with the ARIA practices codepen demo - changing the div to a button. It seems like it might be ok from a quick pass? Kind of nice actually, because then the label can actually be associated with the button as well. Though it would have to be used on a button with type=button, to mitigate the possibility of the button's default submit behavior activating. But to be fair that's a stipulation that would apply to adding any role to a button.

Testing in Chromium browsers with NVDA, JAWS and Narrator, it seems ok?

Would be good to get more robust testing. @ZoeBijl can you give this a spin as well? https://codepen.io/scottohara/pen/LYjoXxX

JAWS-test commented 2 years ago

The advantage of a button over a div would be that with Windows contrast adjustment, the drop down element would be more recognizable as an interactive element

JAWS-test commented 2 years ago

@scottaohara

Your example does not work in Firefox (JAWS and NVDA). However, this is also true for the original WAI-ARIA Authoring Practices 1.2 example. The cause is a bug in Firefox that

But this does not speak against the suggestion of @ZoeBijl, because once the Firefox bug is fixed, it should work with div and button

scottaohara commented 2 years ago

Thanks for the heads up @JAWS-test. Is there presently a bug for this gap in firefox's bug tracker, that you might be aware of?

JAWS-test commented 2 years ago

@scottaohara

https://bugzilla.mozilla.org/show_bug.cgi?id=1702392 https://bugzilla.mozilla.org/show_bug.cgi?id=1631693 https://bugzilla.mozilla.org/show_bug.cgi?id=1732284

JAWS-test commented 2 years ago

Safari and VoiceOver:

But this doesn't mean you shouldn't allow combobox on button either

scottaohara commented 2 years ago

thank you