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 background colors when CSSVarsProvider is used #12901

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

cherniavskii
Copy link
Member

@cherniavskii cherniavskii commented Apr 25, 2024

@cherniavskii cherniavskii added bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! labels Apr 25, 2024
@mui-bot
Copy link

mui-bot commented Apr 25, 2024

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

Generated by 🚫 dangerJS against 3ecc01e


const removeOpacity = (color: string) => `rgb(from ${color} r g b / 1)`;
function blendCssVars(background: string, overlay: string, opacity: number) {
return `color-mix(in srgb,${background}, ${removeOpacity(overlay)} calc(${opacity} * 100%))`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't sure if we could use color-mix. What are our supported browser versions?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted to validate this approach.
color-mix requires iOS >= 16.2, while we currently support >= 15.4. Same for Safari on MacOS. Other browsers seem to match what we have in our browserslist.

Do you have other ideas for solving this issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is the only thing that could work with CSS variables.

@cherniavskii cherniavskii marked this pull request as ready for review September 19, 2024 22:36

const removeOpacity = (color: string) => `rgb(from ${color} r g b / 1)`;
function blendCssVars(background: string, overlay: string, opacity: number) {
return `color-mix(in srgb,${background}, ${removeOpacity(overlay)} calc(${opacity} * 100%))`;
Copy link
Member Author

Choose a reason for hiding this comment

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

@KenanYusuf What do you think about this approach?

Copy link
Member

Choose a reason for hiding this comment

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

@cherniavskii I left a comment here regarding color-mix #14550 (comment)

I think it's a great alternative and does exactly what we need besides the couple of versions of Safari that do not support it.

KenanYusuf

This comment was marked as duplicate.

Copy link
Member

@KenanYusuf KenanYusuf left a comment

Choose a reason for hiding this comment

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

Tested with the additional hover/selected states in #14550 and it is working well.

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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] inconsistent background of a cell when hovering on a row
4 participants