-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: Fix inaccessible disabled Button
s
#62306
Conversation
Size Change: -197 B (-0.01%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
cb8e110
to
01d28f2
Compare
Flaky tests detected in f95b0b2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9768317028
|
@@ -326,6 +326,8 @@ function UnforwardedRangeControl( | |||
<ActionRightWrapper> | |||
<Button | |||
className="components-range-control__reset" | |||
// If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence. | |||
__experimentalIsFocusable={ ! disabled } | |||
disabled={ disabled || value === undefined } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bug in the disabled
logic here (value
will never be undefined), extracted as a separate issue in #63061.
@@ -58,6 +58,7 @@ function ListBox( { | |||
id={ `components-autocomplete-item-${ instanceId }-${ option.key }` } | |||
role="option" | |||
aria-selected={ index === selectedIndex } | |||
__experimentalIsFocusable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled items in a popover menu should be perceivable.
@@ -199,6 +199,7 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) { | |||
? control.role | |||
: 'menuitem' | |||
} | |||
__experimentalIsFocusable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled items in a dropdown menu should be perceivable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled toolbar buttons should always be perceivable.
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
// TODO: Should be focusable disabled, but adding `__experimentalIsFocusable` will trigger a | ||
// focus bug when ToolbarButton is disabled via the `disabled` prop. | ||
// Must address first: https://github.com/WordPress/gutenberg/issues/63070 | ||
// eslint-disable-next-line no-restricted-syntax | ||
disabled={ isDisabled } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to fix this one after #63070 is addressed.
@@ -60,6 +60,7 @@ function UnforwardedToolbarButton( | |||
className | |||
) } | |||
isPressed={ isActive } | |||
__experimentalIsFocusable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled toolbar buttons should always be perceivable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
IMO it would be better to require a disable reason
for both adding more context for future contributors, and to increase the accountability of anyone deciding to ignore the lint rule in the future.
* Components: Fix inaccessible disabled `Button`s * Fix in RangeControl * Fix in ToolbarButton * Fix unit test * List block: Try normalizing `disabled` * Revert "Fix in ToolbarButton" This reverts commit 2cea1eb. * Revert "List block: Try normalizing `disabled`" This reverts commit f95b0b2. * ToolbarButton: Defer fix * Revert "Fix unit test" This reverts commit ed03d97. * Add changelog * ToolbarButton: Add back focusable when not within ToolbarItem * Revert "Revert "Fix unit test"" This reverts commit 5f92fdc. Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
Follow-up to #62080 and #62301
What?
Adds the restricted syntax lint rules for components to the
@wordpress/components
files, and addresses the existing violations.Why?
As part of an effort to maintain accessibility standards
Testing Instructions
✅
npm run lint:js
should pass