-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Replace clickable div elements with buttons in the Add template modal. #42668
Conversation
Size Change: +72 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
This one looks straight forward. I will test this soon if no one else gets to it first. |
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.
Thank you for working on this, @afercia ! It's definitely an improvement to the accessibility.
Even if this PR has already been merged, I've left my feedback in an inline comment.
> div { | ||
text-align: center; | ||
cursor: pointer; | ||
> .components-button { |
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.
Overriding styles of a component from the @wordpress/components
package this way is not ideal:
- we should not use hardcoded
@wordpress/components
classnames, as they are intended to be implementation details and they are not part of the components' public APIs. Instead, we should assign aclassName
to the component we'd like to target (in this case, theFlexItem
), and use that new classname as the CSS selector - more in general, the amount of style overrides that are being applied to this button is worrying me a little. We should really try to limit those to a minimum (setting width/height, margin). If we find that our components can't fulfil our designs, we should discuss this mismatch and either update the designs, or update the components. Style overrides, such this specific one, can be a big obstacle to maintaining and improving the components package
I know that most of these issues existed before this PR, but it's this PR that brought this code snippet to my attention
Fixes #42461
What?
Click or keyboard event should never, ever, be used on non-interactive elements like a
<div>
. That would render a control that is not operable with a keyboard, as it's not focusable. The general issue has been split out to #42540. This PR seeks to fix an instance where aclick
event is attached to a<div>
element in the Add template modal.Why?
In the Add template modal, the choice between creating a template for all items or for a specific item is not operable with a keyboard.
How?
Button
components.Testing Instructions
<button>
elements.Screenshots or screencast