-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[data grid] Columns selection component losing anchorElement/scroll state #13436
Comments
@russ0133 in the meantime could you try to replicate this in a minimal live code example? Especially helpful would be to know if you memoize the panel in some way or not! |
There's no memoization. And yeah, the component itself is inside a MUI Popper and we pass the ref to the button to the columns panel component, the anchorEl being the "Columns" button in the toolbar. I've tried setting the anchorEl without the ref and instead through slotProps in but with no success. Will try to get a minimal live code going and debug further. This seems to only happen when the server updates - if it's only on the frontend side, then it doesn't "remount" the component. |
Resolved the issue by not passing props directly to the toolbar function:
Instead passing the props on the slotProps in the DataGrid:
Also followed this codesandbox and instead of useRef, I'm using useState https://codesandbox.io/p/sandbox/old-forest-9dlvdd?file=%2Fsrc%2FDemo.tsx%3A12%2C31-16%2C2 |
@russ0133: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
The problem in depth
We are running everything on server side (filtering, hiding etc) and we have a custom toolbar component and a custom columnsPanel component. We have been going through an issue for quite some time where (I assume) when the data (rows, columns) state is re-rendered (for example, when hiding a column or reordering columns) the columnsPanel component is completely unmounted and mounted and thus leading us to lose the scroll state. (that on x-data-grid v5.17.26)
This was an issue which we largely ignored until we upgraded x-data-grid to v7.5.0 and now we not only lose the scroll state, but also the anchorEl state... I have a gut feeling that those bugs are related (or the same) and made worse in recent versions of datagrid.
Screen_Recording_2024-02-14_at_4.27.23_PM.mov
Screencast_from_2024-06-07_19-00-00.webm
Your environment
`npx @mui/envinfo`
System:
OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
Binaries:
Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
npm: 9.4.0 - ~/.nvm/versions/node/v18.13.0/bin/npm
pnpm: 9.2.0 - ~/.nvm/versions/node/v18.13.0/bin/pnpm
Browsers:
Chrome: 125.0.6422.141
npmPackages:
@emotion/react: ^11.11.4 => 11.11.4
@emotion/styled: ^11.11.5 => 11.11.5
@mui/icons-material: ^5.15.16 => 5.15.18
@mui/lab: 5.0.0-alpha.170 => 5.0.0-alpha.170
@mui/material: ^5.15.16 => 5.15.18
@mui/styles: ^5.15.18 => 5.15.18
@mui/x-data-grid: ^7.5.0 => 7.5.0
@mui/x-data-grid-pro: ^7.5.0 => 7.5.0
@mui/x-date-pickers-pro: ^6.20.0 => 6.20.0
@mui/x-license: ^7.0.0 => 7.2.0
@mui/x-tree-view: ^7.6.1 => 7.6.1
@types/react: ^18.2.79 => 18.3.2
react: ^18.2.0 => 18.3.1
react-dom: ^18.2.0 => 18.3.1
typescript: ^5.4.5 => 5.4.5
Search keywords: column selection, re-render
Order ID: 91870
The text was updated successfully, but these errors were encountered: