flat-fuchsia
flat-fuchsia2h ago

MUI DeleteButton no longer working

After upgrading to Refine v5, the <DeleteButton> is no longer working, even preventing all the buttons after it to show. The implementation is pretty straightforward
import {
DeleteButton,
EditButton,
ShowButton,
} from "@refinedev/mui";

renderCell: function render({ row }) {
return (
<>
<EditButton hideText recordItemId={row.id} />
<DeleteButton hideText recordItemId={row.id} />
<ShowButton hideText recordItemId={row.id} />
</>
);
}
import {
DeleteButton,
EditButton,
ShowButton,
} from "@refinedev/mui";

renderCell: function render({ row }) {
return (
<>
<EditButton hideText recordItemId={row.id} />
<DeleteButton hideText recordItemId={row.id} />
<ShowButton hideText recordItemId={row.id} />
</>
);
}
Is there something that must be changed with the new version?
3 Replies
kapa.ai
kapa.ai2h ago
Hi @Vargash. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- After upgrading to Refine v5, there are a few important changes and potential issues to consider regarding the <DeleteButton /> from @refinedev/mui: 1. Component Usage and Props
Your usage of <DeleteButton hideText recordItemId={row.id} /> is correct according to the v5 documentation. The recordItemId prop is required to specify which record to delete, and hideText is valid to show only the icon. This pattern is shown in the official docs and examples, so your implementation is aligned with the expected usage in v5 DeleteButton Properties. 2. Potential Issues After Upgrade
- Dependency Alignment: If you upgraded only some Refine packages, mismatched versions can cause issues. It's recommended to align all @refinedev/* packages to the same version. This has been a source of similar issues in the past GitHub Issue #2099. - Peer Dependencies: With v5, you must ensure all required Material UI packages are installed directly in your project. The migration guide specifies you should install @mui/material, @mui/x-data-grid, and related packages yourself Migration Guide. - Button Bugs: There have been bugs in the past where buttons (including DeleteButton) did not behave as expected, especially with props like disabled. However, your issue seems to be more about rendering and functionality, not just the disabled state GitHub Issue #6513. 3. Troubleshooting Steps - Check for Errors: Look for any console errors related to missing props or peer dependencies. - Version Consistency: Make sure all @refinedev/* packages are on the same v5.x version. - Material UI Installation: Ensure you have installed all required MUI packages:
npm install @mui/material @emotion/react @emotion/styled @mui/lab @mui/x-data-grid

npm install @mui/material @emotion/react @emotion/styled @mui/lab @mui/x-data-grid

- Component Placement: If the <DeleteButton /> is causing all buttons after it to not render, it could be due to a runtime error (e.g., missing required props or a crash in the button's logic). Double-check that row.id is always defined. 4. Example from v5 Docs Here is a minimal example from the v5 documentation, which matches your usage:
import { DeleteButton } from "@refinedev/mui";

const MyDeleteComponent = () => {
return <DeleteButton resource="posts" recordItemId="123" />;
};

import { DeleteButton } from "@refinedev/mui";

const MyDeleteComponent = () => {
return <DeleteButton resource="posts" recordItemId="123" />;
};

And in a DataGrid:
renderCell: function render({ row }) {
return (
<>
<EditButton hideText recordItemId={row.id} />
<DeleteButton hideText recordItemId={row.id} />
<ShowButton hideText recordItemId={row.id} />
</>
);
}

renderCell: function render({ row }) {
return (
<>
<EditButton hideText recordItemId={row.id} />
<DeleteButton hideText recordItemId={row.id} />
<ShowButton hideText recordItemId={row.id} />
</>
);
}

DeleteButton Usage Summary:
Your implementation is correct for Refine v5. The most likely causes for your issue are version mismatches between Refine packages or missing Material UI dependencies. Please ensure all related packages are updated and installed as per the migration guide. If the problem persists after these checks, look for runtime errors in the console for more specific clues. If you need further help, please provide any error messages from the browser console or terminal. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2h ago
<@171884471849713664> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
flat-fuchsia
flat-fuchsiaOP2h ago
I believe the dependencies are allright, prove is that the other two buttons (EditButton and ShowButton) are working correctly. If I explore the page via DevTools on the browser I see that, if EditButton and ShowButton generates an <a> tag as the first element, the DeleteButton generates a <div> tag (without any properties, moreover). Manually changing the div to an a actually make the button (and all the buttons after it) pop up

Did you find this page helpful?