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] Fix theme styleOverrides for actionsCell and actionsCellItem #7635

Draft
wants to merge 4 commits into
base: v6.x
Choose a base branch
from

Conversation

cherniavskii
Copy link
Member

Fixes #7619

@cherniavskii cherniavskii added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! customization: css Design CSS customizability labels Jan 20, 2023
@mui-bot
Copy link

mui-bot commented Jan 20, 2023

Messages
📖 Netlify deploy preview: https://deploy-preview-7635--material-ui-x.netlify.app/

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 648.3 1,052.6 656.7 852.9 169.956
Sort 100k rows ms 781.3 1,191.4 1,191.4 969.14 157.624
Select 100k rows ms 217.2 405.8 267 284.9 68.745
Deselect 100k rows ms 216.7 337.1 261.5 264.28 40.256

Generated by 🚫 dangerJS against 1b2bb39

@@ -211,6 +225,7 @@ function GridActionsCell(props: GridActionsCellProps) {
open={open}
target={buttonRef.current}
position={position}
disablePortal
Copy link
Member Author

Choose a reason for hiding this comment

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

Without it, the styles aren't applied to the elements because they're outside of grid DOM tree

@@ -35,6 +35,9 @@ export const GridRootStyles = styled('div', {
[`&.${gridClasses['root--disableUserSelection']} .${gridClasses.cell}`]:
styles['root--disableUserSelection'],
},
{ [`& .${gridClasses.actionsCell}`]: styles.actionsCell },
{ [`& .${gridClasses.actionsCellItem}`]: styles.actionsCellItem },
{ [`& .${gridClasses.booleanCell}`]: styles.booleanCell },
Copy link
Member Author

Choose a reason for hiding this comment

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

Noticed that booleanCell was missing here. There's probably a lot more of those.

Copy link
Member Author

@cherniavskii cherniavskii Jan 23, 2023

Choose a reason for hiding this comment

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

I wonder if we can automate this instead of adding each one manually.
Some of the classes use &. because they're applied to the root element, others use & . (notice the space) because they're not applied to the root element.
But still, we can do something like this:

overridesResolver: (props, styles) => {
  return Object.keys(gridClasses).map(key => {
    const prefix = isRootClassName ? '&' : '& ';
    return { [`${prefix}.${gridClasses[key]}`]: styles[key] }
  });
}

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 6, 2023
@github-actions
Copy link

github-actions bot commented Feb 6, 2023

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@MBilalShafi MBilalShafi changed the base branch from master to v6.x March 21, 2024 02:45
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! customization: css Design CSS customizability PR: out-of-date The pull request has merge conflicts and can't be merged v6.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Unable to override default props/styling for GridActionsCellItem
3 participants