-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[MobileDatePicker] Fix calling onOpen when readOnly is true #30561
[MobileDatePicker] Fix calling onOpen when readOnly is true #30561
Conversation
@@ -145,7 +145,7 @@ export const PureDateInput = React.forwardRef(function PureDateInput( | |||
'aria-readonly': true, | |||
'aria-label': getOpenDialogAriaText(rawValue, utils), | |||
value: inputValue, | |||
onClick: onOpen, | |||
onClick: !props.readOnly ? onOpen : () => {}, |
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.
onClick: !props.readOnly ? onOpen : () => {}, | |
...(!props.readOnly && { onClick: onOpen }), |
No need to set onClick
at all if readOnly
is set.
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.
Oh yes! Pushed the change. Thanks for the comment
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, thanks for the contribution!
Fixes readOnly MobileDatePicker doesn't work in MUI v5 #29310
Problem:
readOnly
prop is true, clicking on theMobileDatePicker
component opens the date selectorSolution
readOnly
is true before calling onOpen functiondemo