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] Align grid cell tooltip with the column header #14484

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

Conversation

arminmeh
Copy link
Contributor

@arminmeh arminmeh commented Sep 4, 2024

While working on #9954 I have noticed that sometimes the cell values are read twice as well.
This occurs because of the title prop that was added in #7671
Accessibility tools were already showing warnings for this approach.

Since column header component is using tooltip to show the whole content, I have added the same to the cells and removed the title prop.

This introduced a small UX issue, since the cell text content is added directly to the cell container to reduce the number of nodes. Tooltip shows up way below the cell, because it has a default margin relative to the target element.

I have added a default slotProp value for the Tooltip component, to render it just a bit over the bottom border

const tooltipProps = slotProps?.tooltip || {
  slotProps: {
    popper: {
      sx: {
        [`&.${tooltipClasses.popper}[data-popper-placement*="bottom"] .${tooltipClasses.tooltip}`]:
          {
            marginTop: '-5px',
          },
      },
    },
  },
};

With default margins
before
With mt = -5px
after

To allow changes, I repeated this pattern (but with default)

Issue that should bring this topic even further #7323

@arminmeh arminmeh added accessibility a11y 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 labels Sep 4, 2024
@arminmeh arminmeh requested a review from a team September 4, 2024 08:43
@mui-bot
Copy link

mui-bot commented Sep 4, 2024

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

Generated by 🚫 dangerJS against 0f07bbe

@arminmeh arminmeh removed the request for review from a team September 5, 2024 09:07
@arminmeh arminmeh marked this pull request as draft September 5, 2024 09:08
@arminmeh arminmeh marked this pull request as ready for review September 5, 2024 09:35
@arminmeh arminmeh requested a review from a team September 5, 2024 09:36
@@ -30,6 +30,12 @@ const GridColumnHeaderTitleRoot = styled('div', {
whiteSpace: 'nowrap',
fontWeight: 'var(--unstable_DataGrid-headWeight)',
lineHeight: 'normal',
// To prevent Safari adding its own tooltip for truncated text
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This issue is still present on the GridCell, but I couldn't apply the same because it would impact performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y 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.

2 participants