Skip to content

[A11Y] Suggestions for Button component when passing disabled property #125

@ibftcorp

Description

@ibftcorp

This is a recommendation to make the Button more inclusive to all users. The reference for this is across other website, but basically, I will highlight this part of A11Y-101.com:

Now close your eyes and imagine the screen reader reads out all the inputs of a form. You know you're within a form. And normally a form gets submitted by hitting a button. But our form depends on the fact that every input has to be filled out - or something else has to happen before it can be submitted. Thus we disable the button until all the conditions have been fulfilled. All sighted persons will get it. The button is semi-transparent. But when a screen reader doesn't ever reach the button, then he will never indicate that there's a button.

Reference: https://a11y-101.com/development/aria-disabled

What is the issue?

  • As a screen user, I cannot access a button using the keyboard/navigate to this button if the disabled property is there.
  • Users should always be able to press/click on things, and we can send feedback after the press/click. In a signup example, you could present error messages.

How can we fix?

  • We can add a javascript the aria-disabled property to the button, but this alone will cause a few problems, especially if you expect that developers will remember that to make an accessible button, you need to pass aria-disabled instead of the intuitite disabled attribute.
  • Ideal scenario: You create a stimulus integration and when the developer pass the disabled attribute, you ignore internally in the component, and add aria-disabled instead;
  • With stimulus do a simply check if disabled was passed, you cancel the submit/click event propagation with event.preventDefault();

This example is in react, but it's easy to see that is simple javascript: https://github.com/Automattic/vip-design-system/blob/trunk/src/system/Button/Button.tsx#L32-L43

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions