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] Show Column Name in Menu Icon if Header is Too Small #16971

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hlavacz
Copy link
Contributor

@hlavacz hlavacz commented Mar 14, 2025

If the column header width is too small, causing the column title to be hidden when hovering over the menu, display the column name as the menu icon’s title.

Before:
image

After:
image

Copy link

github-actions bot commented Mar 14, 2025

Thanks for adding a type label to the PR! 👍

@mui-bot
Copy link

mui-bot commented Mar 14, 2025

Deploy preview: https://deploy-preview-16971--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 7f3d013

@hlavacz hlavacz changed the title [DataGrid] Enhancement: Column menu Title include Column Name when width is too small [DataGrid] Show Column Name in Menu Icon if Header is Too Small Mar 15, 2025
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Mar 17, 2025
@arminmeh arminmeh added the enhancement This is not a bug, nor a new feature label Mar 17, 2025
@arminmeh arminmeh requested a review from a team March 17, 2025 13:34
@KenanYusuf KenanYusuf self-requested a review March 20, 2025 08:39
Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont have a clean solution for the mentioned case, but it should be something we need to take into consideration!

Comment on lines +52 to +54
const neededWidth =
divRef.current?.parentElement?.firstElementChild?.firstElementChild?.firstElementChild
?.scrollWidth ?? 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can break with custom header renderers, where the first element isn't necessarily a text block, or there are follow-up elements like in the docs example: Custom header renderer

@KenanYusuf
Copy link
Member

I would like to take a look at the issue of overflowing column headers more holistically, but haven't found the time yet. I don't think we should merge this until we have considered other options.

@hlavacz
Copy link
Contributor Author

hlavacz commented Mar 24, 2025

The main reason for this quick fix is that I use it in a data grid with lots of one- or two-digit columns that have long names. And since there’s no hover, it’s not ideal — especially because the users aren’t the best in this use case :) I don’t think it will actually break anything. But of course, any more complex solution is more than welcome. Let me know if I can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants