Giter Site home page Giter Site logo

Comments (8)

garronej avatar garronej commented on June 21, 2024 1

OK, thank you for the extra details.
I was making sure there wasn't anything I can do for you and I am afraid this is effectively the case.

In defense of the MUI team, if they are facing all theses specificity issues it is because they are allowing users to use styled-component instead of @emotion as underlying style engine. ref. It makes their job 10 times harder, I am not sure it's worth it.

from tss-react.

synaptiko avatar synaptiko commented on June 21, 2024 1

Got it, I understand it's not an easy job to support customization, especially with more than one CSS engine. In any case, thanks for you help, feel free to close this issue and let's see if someone from MUI can help or if we just need to refactor the code to increase specificity.

from tss-react.

synaptiko avatar synaptiko commented on June 21, 2024

I checked MUI's issues as well and the only partially related thing I found is mui/material-ui#30727

But it's about "state" rules, while in my case I'm overriding sub-component (slot).

I also took a look on the implementation of Chip to see how classes "resolution" is implemented but I got lost in it. But I can see now that they internally generate styles with specificity 2 for the sub-components: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/Chip.js#L139

But then I'm not sure why classes is exposed at all, if it only can add new style props. Unless I'm missing something important here 🙂

from tss-react.

garronej avatar garronej commented on June 21, 2024

Hi @synaptiko,

I might be able to do something about it but I am not sure.

Is the problem that the collor in the root take priority over the color in deleteIcon?

image

PS: Maybe related: #38

from tss-react.

synaptiko avatar synaptiko commented on June 21, 2024

The issue is specifically about sub-component. Even if color from root is removed, the problem persist. And it's not only about Chip, I had similar issue with a few other components.

Thank you, I'll try to get help from MUI.

from tss-react.

garronej avatar garronej commented on June 21, 2024

Is it that (1) doesn’t take precedence over (2) ?

  deleteIcon: {
    color: theme.palette.primary.contrastText, // (2)
    '&:hover': {
      color: `${theme.palette.primary.contrastText}6`, // (1)
    },
  },

Or is it that neither (1) nor (2) take precedence over an internal MUI style that defines color?

from tss-react.

synaptiko avatar synaptiko commented on June 21, 2024

@garronej It's about specificity of what's generated by withStyles/makesStyles vs what's used by MUI internally for deleteIcon. I've added :hover only as an additional thing one could override but it's not specific to it. Even without :hover the color is not correct as it can be seen here: https://muiv5-problem-with-classes.vercel.app/

Here are the generated styles:
image

image

What's coming from MUI is .mui-hke119 .MuiChip-deleteIcon and what's coming from makeStyles is .tss-wtj64x-deleteIcon. But I would expect classes will merge both under .mui-hke119 .MuiChip-deleteIcon.

from tss-react.

garronej avatar garronej commented on June 21, 2024

I'm interested to have the follow up on this.
And feel free to come back if you think there is something I can do from TSS-react.

from tss-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.