Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to create a button with only aria-disabled #2736

Open
1 task done
n9iels opened this issue Nov 13, 2024 · 0 comments
Open
1 task done

Impossible to create a button with only aria-disabled #2736

n9iels opened this issue Nov 13, 2024 · 0 comments
Labels

Comments

@n9iels
Copy link

n9iels commented Nov 13, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

It is currently impossible to create a HTML button like this: <button aria-disabled="true">click me</button>. Given the following snippet of JSX, where we create two buttons. One explicitly marked as disabled and another one marked as aria-disabled.

<Pressable onPress={() => alert('hello')} disabled>
    <Text>Click me!</Text>
</Pressable>
<Pressable onPress={() => alert('hello')} aria-disabled>
    <Text>Click me!</Text>
</Pressable>

When executing this on a native platform, like the iOS simulator, both buttons are marked with the trait "Not Enabled" when inspecting them with the Accessibility Inspector. When clicking the first button no alert is triggered, when clicking the second button the onPress function is executed and thus an alert is triggered.

While the behavior in a browser is the same, the DOM output does not reflect this. The aria-disabled attributed is stripped away completely. The snippet below shows the output.

<button aria-disabled="true" disabled="" role="button" tabindex="-1" class="..." type="button">
    <div dir="auto" class="css-text-146c3p1">Click me!</div>
</button>
<button role="button" tabindex="0" class="..." type="button">
    <div dir="auto" class="css-text-146c3p1">Click me!</div>
</button>

Expected behavior

On the web-version the aria-disabled attribute should be maintained. However this does not mean that the button should have the property disabled as well. For accessibility reasons it is common practice to only mark the button as disabled with the aria-disabled attribute. This allows a user to still being able to focus the button, additionally click it, and have feedback from the screenreader about the action. When adding the disabled button, most screenreader do not allow to focus the button anymore.

Steps to reproduce

The supplied snippets should be sufficient.

Test case

https://codesandbox.io/p/sandbox/gracious-matan-3vhxly

Additional comments

No response

@n9iels n9iels added the bug label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant