-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[pickers] Always use props.value
when it changes
#15490
[pickers] Always use props.value
when it changes
#15490
Conversation
@@ -235,7 +235,7 @@ export const usePickerValue = < | |||
draft: initialValue, | |||
lastPublishedValue: initialValue, | |||
lastCommittedValue: initialValue, | |||
lastControlledValue: inValueWithTimezoneToRender, | |||
lastControlledValue: inValueWithoutRenderTimezone, |
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 need to store the raw props.value
variable if we want to do a reference comparison
Deploy preview: https://deploy-preview-15490--material-ui-x.netlify.app/ |
inValueWithTimezoneToRender, | ||
)) | ||
) { | ||
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) { |
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 compare the old props.value
with the new props.value
(without any processing done to it)
If it changed:
- We set the new
props.value
in the state - If the new derived
props.value
with the right timezone is not equal to the current draft, we update the draft
aed244b
to
b94d6cc
Compare
Cherry-pick PRs will be created targeting branches: v7.x |
@flaviendelangle I think that the PR only partially fixes the issue. Essentially, we should always keep the bound value as the source of truth, even if it didn't change. In this example, any change should not change the value as with the native input. |
I think we can create a dedicated issue for this exact behavior: #15530 |
Closes #10424