-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
[material] Add global CSS class for readOnly
prop
#32822
[material] Add global CSS class for readOnly
prop
#32822
Conversation
Netlify deploy previewBundle size report |
readOnly
prop
See #26488 (comment) we would need to add this component as a state class so that the name would be |
Resolves mui#26488 This change provides a readOnly class to allow for targetted styling
737c967
to
c323765
Compare
@mnajdova Thank you for the direction, I have updated the code accordingly along with an updated screenshot with the correct class name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, one final comment to avoid breaking change in the Rating
component.
@@ -57,7 +57,11 @@ | |||
"iconActive", | |||
"decimal" | |||
], | |||
"globalClasses": { "disabled": "Mui-disabled", "focusVisible": "Mui-focusVisible" }, | |||
"globalClasses": { | |||
"readOnly": "Mui-readOnly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change we will need to manually add the MuiRating-readOnly
in the Rating component, and add a comment to remove it in v6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff could help:
index f0f2234850..de1020c23c 100644
--- a/packages/mui-material/src/Rating/Rating.js
+++ b/packages/mui-material/src/Rating/Rating.js
@@ -499,7 +499,14 @@ const Rating = React.forwardRef(function Rating(inProps, ref) {
ref={handleRef}
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
- className={clsx(classes.root, className)}
+ className={clsx(
+ classes.root,
+ {
+ // TODO v6: remove this class as it duplicates with the gloabl state class Mui-readOnly
+ 'MuiRating-readOnly': readOnly,
+ },
+ className,
+ )}
ownerState={ownerState}
role={readOnly ? 'img' : null}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with the suggested changes, it doesn't change the outcome of the rating.json file. I'm not sure what to do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix, there was a spelling mistake in the useUtilityClasses
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZeeshanTamboli would you like to finish this up and merge it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll do it.
|
@jrparish are you still interested in completing this PR? As @ZeeshanTamboli noted, it should be a matter of handling the Mui-readOnly class. |
@michaldudak @ZeeshanTamboli Updated to only include class changes |
We should have added |
readOnly
propreadOnly
prop
@@ -498,7 +498,14 @@ const Rating = React.forwardRef(function Rating(inProps, ref) { | |||
ref={handleRef} | |||
onMouseMove={handleMouseMove} | |||
onMouseLeave={handleMouseLeave} | |||
className={clsx(classes.root, className)} | |||
className={clsx( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to apply similar patches in InputBase
as there was quite some time since we added the read only class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did the remaining changes. @jrparish Thanks for your contribution!
Resolves #26488
This change provides a readOnly class to allow for targetted styling