fix(mui): prevent nested interactive elements in navigation buttons#7266
fix(mui): prevent nested interactive elements in navigation buttons#7266kaigritun wants to merge 3 commits intorefinedev:mainfrom
Conversation
Use Button's component prop to render as LinkComponent directly instead of nesting Button inside LinkComponent. This fixes an accessibility issue where button elements were incorrectly nested inside anchor elements. Affects: CreateButton, EditButton, ShowButton, ListButton, CloneButton Fixes refinedev#7085
🦋 Changeset detectedLatest commit: 7237c5c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
refine
|
||||||||||||||||||||||||||||
| Project |
refine
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 18m 38s |
| Commit |
|
| Committer | Özgür Akça |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
22
|
|
|
0
|
|
|
368
|
| View all changes introduced in this branch ↗︎ | |
| <Button | ||
| component={LinkComponent} | ||
| to={to} | ||
| replace={false} |
There was a problem hiding this comment.
Is removing replace intentional?
| onClick(e); | ||
| } | ||
| }} | ||
| style={{ textDecoration: "none" }} |
There was a problem hiding this comment.
The order of props are changed, so the diff is a bit hard to read. Could you try to keep current order as much as possible?
442a79d to
b38da2f
Compare
|
Thanks for the review @BatuhanW! I've addressed both of your comments:
|
Summary
This PR fixes an accessibility issue where navigation buttons (CreateButton, EditButton, ShowButton, ListButton, CloneButton) render a
<button>element inside an<a>element.Problem
The current implementation wraps
<Button>inside<LinkComponent>:This creates nested interactive elements (
<a><button></a>), which:Solution
Use MUI's
componentprop to render the Button as the LinkComponent directly:This approach:
Changes
packages/mui/src/components/buttons/create/index.tsxpackages/mui/src/components/buttons/edit/index.tsxpackages/mui/src/components/buttons/show/index.tsxpackages/mui/src/components/buttons/list/index.tsxpackages/mui/src/components/buttons/clone/index.tsxTesting
The fix maintains backward compatibility - all existing props and behaviors are preserved. The only change is the rendered HTML structure.
Fixes #7085