TableRow hover style override not working
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Style not applied on hover if hover={true} on TableRow component and style override applied in theme
Expected Behavior 🤔
Style applied on hover
Steps to Reproduce 🕹
https://codesandbox.io/s/zealous-currying-l6beb?file=/index.js
Context 🔦
Migrating from v4 to v5. Was working as expected in v4. I want to apply this in the theme overrides rather than in each component - I know there are many other ways to achieve the same thing, but I was under the impression that this should work.
Arguably a table row with the hover prop true
is most likely clickable, so should cursor: ‘pointer’ be applied by default?
Your Environment 🌎
System:
OS: Windows 10 10.0.19043
Binaries:
Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 93.0.4577.82
Edge: Spartan (44.19041.1023.0), Chromium (94.0.992.31)
npmPackages:
@emotion/react: ^11.4.1 => 11.4.1
@emotion/styled: ^11.3.0 => 11.3.0
@mui/core: 5.0.0-alpha.47
@mui/icons-material: ^5.0.0 => 5.0.0
@mui/lab: ^5.0.0-alpha.47 => 5.0.0-alpha.47
@mui/material: ^5.0.0 => 5.0.0
@mui/private-theming: 5.0.0
@mui/styled-engine: 5.0.0
@mui/styles: ^5.0.0 => 5.0.0
@mui/system: 5.0.0
@mui/types: 7.0.0
@mui/utils: 5.0.0
@types/react: 17.0.5
react: ^17.0.0 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
styled-components: ^5.3.1 => 5.3.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
TableRow hover style override not working #28648 - GitHub
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >Overriding TableRow hover CSS on Material-ui in React
But I get this error: the key hover provided to the classes property is not valid for TableRow.
Read more >Disable hover color change / Retain table row color based on ...
Hello All,. Currently I am trying to keep the color retained in certain conditions, e.g. to show the row record as red when...
Read more >TableRow API - Material UI - MUI
Styles applied to the root element if table variant="footer". You can override the style of the component using one of these customization options:...
Read more >Overriding TableRow hover CSS on Material-ui in React-Reactjs
It's because material-ui is based on JSS to style the component. It's a bit disturbing when you are not familiar with it. Here...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @mnajdova , your comment led me to the answer: https://codesandbox.io/s/goofy-gauss-k922m?file=/index.js
It’s worth me clarifying here that I am solely referring to the prop hover, not the pseudo class. The docs for TableRow props (https://mui.com/api/table-row/#props) were what caused me to assume that the
hover
prop could be accessed at the same level asroot
in theme styleOverrides.I realise now that my wording in ‘Expected Behaviour’ was probably misleading, sorry about that.
Thanks for the feedback.
Hover is currently missing from our state classes. That being said, the section about state classes does not explain why we can’t directly style these classes in
stylesOverrides
. The drawback explained does not apply here.@mnajdova Could you explain why the repro is not working and how to document that?
I think we discussed this earlier but we failed again to properly document why that is. Increasing specificity is not mandated by the platform: https://codesandbox.io/s/pseudo-classes-have-no-specificity-z5pl8. We shouldn’t need to. It’s our choice and this choice is still not justified. This is a common footgun for our users so we need to fix it finally.