In my React Js app, I am utilizing Material UI components or MUI v5 as the UI library for my project.
Within the DataGrid
/DataGridPro
component, I am implementing a custom edit and delete row feature.
The requirement is to display edit and delete icons when hovering over a row without adding a new column specifically for actions. An example of this functionality can be seen on a private dashboard https://i.stack.imgur.com/9Wk3p.png
If the user reduces the browser width, instead of hiding the edit and delete icons, the row should be hidden as depicted in these images: https://i.stack.imgur.com/lopHF.png https://i.stack.imgur.com/Ey1wE.png
I have implemented it here https://codesandbox.io/s/learn-mui-data-grid-hover-row-367vh?file=/demo.js, but encountered some limitations:
1. The Popper
component overlaps the DataGrid
component
When hovering over rows that aren't fully visible, the Popper
component appears on top of the DataGrid
like shown in these images:
https://i.stack.imgur.com/WLsVV.png https://i.stack.imgur.com/yjwoo.png
Even setting disablePortal={true}
didn't resolve the issue and rendered the Popper
component outside the row as illustrated here:
https://i.stack.imgur.com/bLLVg.png
Adjusting the zIndex
values did not help either, with the Popper
component still overlapping the DataGrid
:
https://i.stack.imgur.com/KhOts.png
Question 1: How can I ensure the Popper
component remains on top of the row within the DataGrid
?
https://i.stack.imgur.com/TRjOQ.png
2. The Popper
component does not stick to the DataGrid
component
Adding extra columns resulted in the Popper
component sticking at the end of the row, which is desirable:
https://i.stack.imgur.com/0dcrJ.png
However, when scrolling to the beginning of the row, the Popper
component did not stick to the end as intended:
https://i.stack.imgur.com/1dgRI.png
Question 2: How can I make the Popper component consistently adhere to the end of the row despite horizontal scrolling? https://i.stack.imgur.com/ihAAs.png
You can view the demo here: https://codesandbox.io/s/learn-mui-data-grid-hover-row-367vh?file=/Demo2.jsx
Alternatively, is there a more effective approach to achieve this scenario? 🤔