Repository navigation
Question regarding the use of aria-current="true" on <button> elements for selection state #5153
Replies: 2 comments 2 replies
|
@Ignacio-de-Loyola |
|
@Ignacio-de-Loyola I'd go with Detlev's suggestion. aria-pressed is the state ARIA defines for a button that stays "on" after you activate it, and screen readers announce the change right on the focused button, which is the gap the hidden "selected" text and the live region were trying to fill. aria-current means something different: it marks where the user is within a set, like the current page in a nav or the current step in a wizard. It isn't invalid on a button, but "current" is not "selected", and that is what gets announced. aria-expanded doesn't fit either. It is for a control that shows or hides content in the page, not one that opens a modal dialog. If you want to signal the dialog, aria-haspopup="dialog" is the optional hint. One caveat with aria-pressed: it doesn't convey that only one of the three can be on. A visible group label, or a group role around the three buttons, tells the user they belong together. On 3.2.2, buttons sidestep the concern. Activating a button is a user action, not a change of a form control's setting, so the group can keep a radio-like look while the semantics change. If the choice has to be submitted or survive a reload, mirror it in a hidden input and keep the buttons as the interface. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello, I have a question regarding the appropriate use of aria-current in a specific UX scenario.
We have a UI with 3 options. Semantically, these should be marked up as radio buttons. However, the UX dictates that selecting an option immediately opens a dialog.
Because triggering a context change (opening a dialog) on radio button selection violates WCAG 3.2.2 On Input, we changed the markup to use
<button>elements instead.Current Implementation & Problem:
Initially, we appended hidden text (e.g., "selected") inside the chosen . However, screen readers did not reliably announce this state change immediately. To resolve this, we implemented an aria-live region to announce the "selected" state, but this has made our logic overly complex.
Proposed Solution:
To simplify the implementation, we are considering using aria-current="true" on the selected
<button>to indicate its active/selected state to screen readers.Questions:
Does using aria-current="true" on a element to indicate a selected option violate ARIA specifications?
Are there any known use cases, reference implementations, or best practices where aria-current is used on
<button>elements for indicating selection? (Or would another attribute like aria-pressed or aria-expanded be more appropriate given the dialog trigger?)All reactions