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

[Rating] Add TODO comment in Rating component to use readOnly state class #36357

Merged

Conversation

ZeeshanTamboli
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli commented Feb 27, 2023

With the advent of readOnly global state class in #32822, we also need to add it in the list of state classes that is used to trigger the CSS specificity warning when overriding in theme. We missed it in #32822.

I refactored it to keep it defined in one place only. Otherwise, this would be easy to miss in future.

@ZeeshanTamboli ZeeshanTamboli changed the title [] Add readOnly in state class list [theme] Add readOnly in state class list Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work customization: theme Centered around the theming features labels Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [theme] Add readOnly in state class list [material] Add readOnly in state class list Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [material] Add readOnly in state class list [core] Add readOnly in state class list Feb 27, 2023
@mui-bot
Copy link

mui-bot commented Feb 27, 2023

Netlify deploy preview

https://deploy-preview-36357--material-ui.netlify.app/

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against f6794c0

@ZeeshanTamboli ZeeshanTamboli changed the title [core] Add readOnly in state class list [material] Add readOnly in state class list Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli added the package: material-ui Specific to @mui/material label Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [material] Add readOnly in state class list [material] Add readOnly in state class list to trigger warning Feb 27, 2023
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

The changes makes sense, however in this moment the Rating component does not increases the specificity for the readOnly state. We could introduce this breaking changes in the next major release. The error currently is kind of not reflecting the correct state of things, which may be confusing. Let's add in https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Rating/Rating.js#L106 comment for using the state class in v6.

@ZeeshanTamboli ZeeshanTamboli changed the title [material] Add readOnly in state class list to trigger warning [material] Add TODO comment in Rating component to use readOnly state class Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli changed the title [material] Add TODO comment in Rating component to use readOnly state class [Rating] Add TODO comment in Rating component to use readOnly state class Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli added component: rating This is the name of the generic UI component, not the React module! and removed customization: theme Centered around the theming features labels Feb 27, 2023
@ZeeshanTamboli
Copy link
Member Author

ZeeshanTamboli commented Feb 27, 2023

The changes makes sense, however in this moment the Rating component does not increases the specificity for the readOnly state. We could introduce this breaking changes in the next major release. The error currently is kind of not reflecting the correct state of things, which may be confusing. Let's add in https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Rating/Rating.js#L106 comment for using the state class in v6.

Oh okay. I didn't notice that the Rating component uses ownerState instead. I reverted the previous changes and added the comment. I reverted because it may unnecessarily throw an error even if it works without a need to increase specificity in the theme.

I wonder whether it is better to use ownerState in future to apply conditional styles internally in our components?

@mnajdova
Copy link
Member

mnajdova commented Feb 27, 2023

I wonder whether it is better to use ownerState in future to apply conditional styles internally in our components?

This is always the recommended approach, except for the state classes, so that we are closer to the CSS pseudo selectors. For e.g. in plain CSS you would have: .some-classname:disabled, which in our world, maps to: .some-classname.Mui-disabled.

@ZeeshanTamboli ZeeshanTamboli merged commit cccae49 into mui:master Feb 27, 2023
@ZeeshanTamboli ZeeshanTamboli deleted the add-readOnly-in-state-class-list branch February 27, 2023 12:37
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: rating This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants