-
Notifications
You must be signed in to change notification settings - Fork 83
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
fix(pod): make edit button an HTML button rather than an anchor tag #6361
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c1c57a2:
|
72081b4
to
ee39372
Compare
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.
Everything looks OK to me. Just this what we discussed privately basically. Looks like the edit
button can now be focused but it appears to be the incorrect focus styling (Focus Redesign set to true on the screenshot btw). It looks like this will have existed before your change but now that edit
button can be focused, this has been brought to light.
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.
Looks good to me, nothing more to add in addition to @DipperTheDan's comment
Fix accessibility by ensuring the edit button is an actual button, rather than an anchor tag with no href. This makes it possible to interact with the button with the keyboard as well as with a screenreader. BREAKING CHANGE: The onEdit prop is now restricted to being an event handler function - the options for it to be a string or an object have been removed.
ee39372
to
98d8bde
Compare
🎉 This PR is included in version 122.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fix accessibility by ensuring the edit button is an actual button, rather than an anchor tag with no href. This makes it possible to interact with the button with the keyboard as well as with a screenreader.
BREAKING CHANGE: The onEdit prop is now restricted to being an event handler function - the options for it to be a string or an object have been removed.
Proposed behaviour
When the
onEdit
prop is provided, the Edit button should be an HTML<button>
element, allowing it to be focused with the keyboard and to be accessible using a screenreader. There should be no Axe errors from such a component.Only functions should be valid values for this prop.
Current behaviour
The edit button is rendered as an HTML
<a>
tag but without anhref
, which is a non-interactive element - therefore it is not possible to trigger the edit action using a screenreader (Voiceover on Mac announces it as simply "empty group"), nor can it be focused by using the tab/shift-tab keys on a keyboard. Axe reports an error "elements must only use valid ARIA attributes", as we pass anaria-label
which is not valid (and not even read out by many screenreaders) for such a non-semantic element.Strings and objects are valid to use for the
onEdit
prop's value, although they do result in a deprecation warning.Checklist
d.ts
file added or updated if requiredQA
Additional context
Testing instructions
The following CodeSandbox is an example of the broken behaviour.
You can see the new behaviour by looking at the version in the comment by
codesandbox[bot]
.