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

Button: Never apply aria-disabled to anchor #63376

Merged
merged 2 commits into from
Jul 11, 2024
Merged

Conversation

mirka
Copy link
Member

@mirka mirka commented Jul 10, 2024

Fixes #62281

What?

Prevents link (anchor) buttons from ever having an aria-disabled attribute.

Why?

<Button href="foo"> automatically renders an anchor element, whereas <Button href="foo" disabled> will remain a button element, because anchor elements cannot be disabled. Neither disabled nor aria-disabled are valid attributes on an anchor.

However, there was a bug where <Button href="foo" disabled accessibleWhenDisabled> rendered an anchor with an aria-disabled attribute.

Testing Instructions

See the Storybook for Button and see what happens when you render <Button href="foo" disabled accessibleWhenDisabled>.

✅ New unit test should also pass.

@mirka mirka added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Jul 10, 2024
@mirka mirka self-assigned this Jul 10, 2024
@mirka mirka requested a review from ajitbohra as a code owner July 10, 2024 17:54
Copy link

github-actions bot commented Jul 10, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mirka mirka requested review from afercia and a team July 10, 2024 17:55
Copy link

Flaky tests detected in f1ddeaa.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9879092432
📝 Reported issues:

Copy link
Contributor

@DaniGuardiola DaniGuardiola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me and work as intended!

Random idea for discussion, tangential to this PR, but do you think it'd be possible to use an Ariakit button underneath? We might be able to delegate many of these behaviors (like accessibleWhileDisabled), plus get a few potential safeguards or a11y features out of the box and reduce our maintenance area. Not sure if there'd be any significant trade-offs.

Copy link
Contributor

@DaniGuardiola DaniGuardiola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me and work as intended!

Random idea for discussion, tangential to this PR, but do you think it'd be possible to use an Ariakit button underneath? We might be able to delegate many of these behaviors (like accessibleWhileDisabled), plus get a few potential safeguards or a11y features out of the box and reduce our maintenance area. Not sure if there'd be any significant trade-offs.

@DaniGuardiola
Copy link
Contributor

Github decided to duplicate my review 😆

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks for making this behavior clearer through a unit test 👍

@ciampo
Copy link
Contributor

ciampo commented Jul 11, 2024

We might be able to delegate many of these behaviors (like accessibleWhileDisabled), plus get a few potential safeguards or a11y features out of the box and reduce our maintenance area. Not sure if there'd be any significant trade-offs.

That is an alluring idea, although Button is such a complex and ubiquitous component that we'd need to do extensive testing, both automated (behavioral and visual) and human, before making such a change. I wonder if it just makes more sense to think about a v2 of Button instead — although likely neither of those projects would be high priority.

@mirka
Copy link
Member Author

mirka commented Jul 11, 2024

Basically agree with @ciampo. But my instinct is that Ariakit is not going to make a big difference here, because most of the complexity of Button is in the prop bloat and the styles 😅

@mirka mirka merged commit 48aa7d5 into trunk Jul 11, 2024
66 checks passed
@mirka mirka deleted the fix/button-href-aria-disabled branch July 11, 2024 12:17
@github-actions github-actions bot added this to the Gutenberg 18.9 milestone Jul 11, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
* Button: Never apply `aria-disabled` to anchor

* Add changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: DaniGuardiola <daniguardiola@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Bug An existing feature does not function as intended
4 participants