FlexItem should not allow onClick prop when it renders a non-interactive element #42461
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
Description
The
FlexItem
component renders a<div>
element by default. It can render other elements via theas
prop.When it renders an element that is not operable with a keyboard, it should not allow an
onClick
prop. Maybe, it should never allow anonClick
prop.An example of incorrect implementation is in
AddCustomTemplateModal
:The two choices at the bottom of the modal are just clickable
<div>
elements.The can't be operated with a keyboard.
We should never, ever, use clickable divs or other non-interactive clickable elements.
This specific implementation in
AddCustomTemplateModal
can be probably fixed by using theas
prop to render the flex item as aButton
component and then adjust the style. Also, the buttons don't need to contain a heading (the H5 is a wrong heading level anyways).However, a more future-proof measure would be to not allow an
onClick
prop.Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: