Review main Merged

85985[TASK] Improve a11y of anchors created via `LinkButton`

Ayke Halder CR +2 V +2 Easy +32 −1 updated 12/18/24, 15:11

Commit message

This adds `role="button"` and uses `aria-disabled="true"` for anchors
created via `LinkButton`.

Before the non-working attribute `disabled` was implemented for the
`a`-tag.

Reference/information:

MDN:
https://developer.mozilla.org/en-US/docs/Web/HTML
Easy readable.

WHATWG HTML Standard:
https://html.spec.whatwg.org/multipage/
Kind of readable.

W3C: Accessible Rich Internet Applications (WAI-ARIA)
https://w3c.github.io/aria/#aria-disabled
Only read for details.

About disabled-attribute:

MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled#overview
WHATWG: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
The disabled attribute is supported by <button>, <fieldset>, <optgroup>, <option>, <select>, <textarea> and <input>.

So disabled attribute is not supported by html-element <a>.

Additional about role="button"-attribute:

MDN: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role
WAI-ARIA: https://w3c.github.io/aria/#button
WHATWG: https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks
MDN:

Adding role="button" tells the screen reader the element is a button, but provides no button functionality.

WHATWG:

The addition of an ARIA role and various ARIA states and properties helps convey semantics to accessibility technology. […] And setting the aria-disabled state to "true" when the button is logically disabled conveys to accessibility technology the button's disabled state.

So role="button" does not convert the <a>-element into a<button>-element. And thereby the disabled-attribute can still not be used for<a role="button">`.

Attention:
Actually it's always better to use real <button>-elements when possible, as otherwise all the states must be re-implmented using JavaScript.
(My opinion - and also supported by others.)

Also see:

https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks
About aria-disabled-attribute:

MDN: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled
WAI-ARIA: https://w3c.github.io/aria/#aria-disabled
MDN:

Unlike HTML's disabled Boolean attribute, which will communicate a form control as semantically being disabled, change its styling to reflect its state and suppress all functionality along with disallowing the element's value from participating in form submission, the aria-disabled="true" only semantically exposes these elements as being disabled. Web developers must manually ensure such elements have their functionality suppressed when exposed to the disabled state.

Use the aria-disabled-attribute whenever there is no option to use the disabled-attribute - and re-implement all functional implications (e.g. not clickable) by JavaScript.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
  • Verified V +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1116

  1. Ayke Halder uploaded patch set 1 09/10/24, 16:38

  2. core-ci voted on patch set 1 V -1 09/10/24, 16:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65289

  3. Ayke Halder rebased onto patch set 2 V -1 09/10/24, 18:29

  4. core-ci voted on patch set 2 V +1 09/10/24, 18:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65319

  5. Ayke Halder rebased onto patch set 3 V +1 11/22/24, 07:12

  6. core-ci voted on patch set 3 V +1 11/22/24, 07:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/70016

  7. Benni Mack commented on patch set 3 12/17/24, 16:52

    thanks for the patch, do you have a reference / information on when to use "aria-disabled" vs. "disabled" as attributes?
  8. Ayke Halder commented on patch set 3 12/18/24, 13:51

    Reply

    Reference/information: * MDN: https://developer.mozilla.org/en-US/docs/Web/HTML Easy readable. * WHATWG HTML Standard: https://html.spec.whatwg.org/multipage/ Kind of readable. * W3C: Accessible Rich Internet Applications (WAI-ARIA) https://w3c.github.io/aria/#aria-disabled Only read for details. ---- About `disabled`-attribute: * MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled#overview * WHATWG: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute > The `disabled` attribute is supported by `<button>`, `<fieldset>`, `<optgroup>`, `<option>`, `<select>`, `<textarea>` and `<input>`. So `disabled` attribute is not supported by html-element `<a>`. ---- Additional about `role="button"`-attribute: * MDN: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role * WAI-ARIA: https://w3c.github.io/aria/#button * WHATWG: https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks MDN: > Adding role="button" tells the screen reader the element is a button, but **provides no button functionality**. WHATWG: > The addition of an ARIA role and various ARIA states and properties helps convey semantics to accessibility technology. […] And setting the aria-disabled state to "true" when the button is logically disabled conveys to accessibility technology the button's disabled state. So `role="button"` does not convert the `<a>-element into a `<button>`-element. And thereby the `disabled`-attribute can still not be used for `<a role="button">`. **Attention:** Actually it's **always** better to use real `<button>`-elements when possible, as otherwise all the states must be re-implmented using JavaScript. (My opinion - and also supported by others.) Also see: * https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks ---- About `aria-disabled`-attribute: * MDN: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled * WAI-ARIA: https://w3c.github.io/aria/#aria-disabled MDN: > Unlike HTML's disabled Boolean attribute, which will communicate a form control as semantically being disabled, change its styling to reflect its state and suppress all functionality along with disallowing the element's value from participating in form submission, the aria-disabled="true" only semantically exposes these elements as being disabled. Web developers must manually ensure such elements have their functionality suppressed when exposed to the disabled state. Use the `aria-disabled`-attribute whenever there is no option to use the `disabled`-attribute - and re-implement all functional implications (e.g. not clickable) by JavaScript. .
  9. Oli Bartsch updated the commit message in patch set 4 V +1 12/18/24, 14:48

  10. Oli Bartsch voted on patch set 4 CR +1 V +1 12/18/24, 14:48

  11. core-ci voted on patch set 4 V +1 12/18/24, 14:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71390

  12. Oli Bartsch updated the commit message in patch set 5 CR +1 V +1 12/18/24, 14:58

  13. Oli Bartsch voted on patch set 5 CR +1 V +1 12/18/24, 14:58

  14. core-ci voted on patch set 5 V +1 12/18/24, 15:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71393

  15. Benni Mack voted on patch set 5 CR +2 V +2 12/18/24, 15:11

  16. Benni Mack merged patch set 6 12/18/24, 15:11