Skip to content
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

[DataGrid] onColumnVisibilityModelChange gets triggered when columnVisibilityModel is provided and column width is changed. #3725

Closed
2 tasks done
tielushko opened this issue Jan 24, 2022 · 8 comments · Fixed by #3735
Assignees
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! plan: Pro Impact at least one Pro user

Comments

@tielushko
Copy link

tielushko commented Jan 24, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

The onColumnVisibilityModelChange event gets fired when provided with initial columnVisibilityModel and resizing column width.

In my application, I have the custom width preferences that I store for the columns. When I use the controlled columnVisibilityModel however, the resize of the column triggers the onColumnVisibilityModelChange.

Please see the sandbox here:
Sandbox

Expected behavior 🤔

Resizing the column should not trigger the onColumnVisibilityModelChange event.

Steps to reproduce 🕹

Steps:

  1. Hide any controlled column.
  2. Resize any column.
  3. In console, check the triggered column event and noticed that the changes applied to visibility got reset.

Context 🔦

No response

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Order ID 💳 (optional)

31986

@tielushko tielushko added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 24, 2022
@tielushko
Copy link
Author

Update: Here is the cleaner sandbox that indicates the issue with visibility change getting triggered on resize of the column. Using DataGridPro.

https://codesandbox.io/s/visiblecolumnsmodelcontrolled-material-demo-forked-sisyo?file=/demo.js

@cherniavskii
Copy link
Member

cherniavskii commented Jan 24, 2022

Thanks @tielushko !
I can reproduce the issue.
A bit simplified example: https://codesandbox.io/s/visiblecolumnsmodelcontrolled-material-demo-forked-8mh8v?file=/demo.js

@cherniavskii cherniavskii added bug 🐛 Something doesn't work regression A bug, but worse component: data grid This is the name of the generic UI component, not the React module! plan: Pro Impact at least one Pro user and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer regression A bug, but worse labels Jan 24, 2022
@flaviendelangle
Copy link
Member

Good catch, I'm resetting the visibility status of all the columns when updating just on column.
I'll make a quick fix on the next release 👍

@tielushko
Copy link
Author

Thanks @flaviendelangle for your quick effort!

@flaviendelangle flaviendelangle changed the title onColumnVisibilityModelChange gets triggered when columnVisibilityModel is provided and column width is changed. [DataGrid] onColumnVisibilityModelChange gets triggered when columnVisibilityModel is provided and column width is changed. Jan 31, 2022
@joaquim21acj
Copy link

I have this version on my project and the issue still remains.

"@mui/x-data-grid-premium": "^5.17.26",

@sandronominal
Copy link

@flaviendelangle I'm also experiencing same issue.
"@mui/x-data-grid-premium": "^7.21.0",

@flaviendelangle
Copy link
Member

@michelengelen I let you handle this one 🙏

@cherniavskii
Copy link
Member

@sandronominal Can't reproduce: https://codesandbox.io/p/sandbox/visiblecolumnsmodelcontrolled-material-demo-forked-t39l45
Please open a new issue with a minimal reproduction example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! plan: Pro Impact at least one Pro user
Projects
None yet
5 participants