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

ToolbarButton: Always keep focusable when disabled #63102

Merged
merged 5 commits into from
Jul 4, 2024

Conversation

mirka
Copy link
Member

@mirka mirka commented Jul 3, 2024

Fixes #57701

What?

Keeps disabled ToolbarButtons focusable in all instances.

Why?

Toolbar/menu items are one of the UI elements that are generally recommended to keep focusable when disabled.

Testing Instructions

Play around with the Storybook code for the ToolbarButtons in the Toolbar story. Passing disabled should keep the button focusable.

@mirka mirka added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components labels Jul 3, 2024
@mirka mirka self-assigned this Jul 3, 2024
@mirka mirka force-pushed the toolbar-button-focusable-disabled branch from 9dffdb2 to c985641 Compare July 3, 2024 20:41
@mirka mirka force-pushed the toolbar-button-focusable-disabled branch from c985641 to 731f369 Compare July 3, 2024 21:11
@mirka mirka marked this pull request as ready for review July 3, 2024 21:14
@mirka mirka requested a review from ajitbohra as a code owner July 3, 2024 21:14
Copy link

github-actions bot commented Jul 3, 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: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@@ -50,6 +50,7 @@ function ToolbarItem(

return (
<Ariakit.ToolbarItem
accessibleWhenDisabled
Copy link
Member Author

@mirka mirka Jul 3, 2024

Choose a reason for hiding this comment

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

I don't foresee a need for it, but technically a consumer can override this by passing accessibleWhenDisabled={ false }. This is currently undocumented on our end, but we could document it if it ever becomes a need.

@mirka mirka requested a review from a team July 3, 2024 21:17
Copy link

github-actions bot commented Jul 3, 2024

Flaky tests detected in a5b11eb.
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/9792483814
📝 Reported issues:

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

🚀

packages/components/src/toolbar/toolbar-button/types.ts Outdated Show resolved Hide resolved
packages/components/src/toolbar/toolbar-button/index.tsx Outdated Show resolved Hide resolved
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.

LGTM 👍

Noting that in 406ef77 which I added to #63107 I'm suggesting to use the new stable prop, but this won't be necessary if this PR lands first - instead we'll have to remove the experimental prop usage.

Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
@mirka
Copy link
Member Author

mirka commented Jul 4, 2024

Noting that in 406ef77 which I added to #63107 I'm suggesting to use the new stable prop, but this won't be necessary if this PR lands first - instead we'll have to remove the experimental prop usage.

Good catch, thanks! I guess I'll do a cleanup & normalization pass in a separate PR. I've seen some aria-disabled and accessibleWhenDisabled usage here and there that should be cleaned up too.

@mirka mirka enabled auto-merge (squash) July 4, 2024 10:14
@mirka mirka merged commit 9d4176c into trunk Jul 4, 2024
61 checks passed
@mirka mirka deleted the toolbar-button-focusable-disabled branch July 4, 2024 10:44
@github-actions github-actions bot added this to the Gutenberg 18.8 milestone Jul 4, 2024
@talldan
Copy link
Contributor

talldan commented Jul 9, 2024

I noticed that since this PR was merged there seem to be some styling changes in the block toolbar.

Before:
Screenshot 2024-07-09 at 5 43 49 pm

After:
Screenshot 2024-07-09 at 4 51 32 pm

It's possible (very likely) the block toolbar styles are implemented incorrectly, so it might not be the fault of this PR, but thought I'd mention it.

@mirka
Copy link
Member Author

mirka commented Jul 9, 2024

@talldan Is there a special repro condition for that? This is what I'm seeing at current trunk 8b470e0

Default

Block toolbar

All locked

Block toolbar for all locked block
@talldan
Copy link
Contributor

talldan commented Jul 9, 2024

Oh, sorry, for some reason I didn't include any 🤦

If you edit any page in the site editor, and try selecting a template part block, the toolbar shows what it does in my comment.

@mirka
Copy link
Member Author

mirka commented Jul 9, 2024

Ah ok, got it. That color is easy to fix, but when we take consistency and accessibility into consideration, I'm not sure if/how we should fix it 🤔 For example, it is in fact visibly grayed out in the "All locked" case I posted.

I do think the button needs to remain focusable, but if so we need to visually show that it's disabled. Maybe something like this?

CleanShot.2024-07-09.at.19.42.31.mp4

But all in all, I'm leaning toward predictability/consistency, which is to visually gray out as usual when a button is disabled. It's potentially confusing to even a sighted mouse user if an enabled-looking button is unresponsive. What do you think?

carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
* ToolbarButton: Always keep focusable when disabled

* Omit `__experimentalIsFocusable` from TS types

* Fixup

* Add changelog

* Clarify deprecation comment

Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>

---------

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended
4 participants