-
-
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 the same timezone in the field, the view and the layout components #13481
Conversation
… layout components
@@ -165,19 +165,31 @@ export const usePickerValue = < | |||
const { | |||
onAccept, | |||
onChange, | |||
value: inValue, | |||
value: 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.
I'm using a super explicit variable name here to lower the risk of re-using the variable below instead of the one with the right timezone.
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.
Do you think that having inValue
and inValueWithTimezone
would not be enough? 🤔
Or even as we have everywhere else: inValue
and value
for the value returned from useValueWithTimezone
..? 🤔
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.
The issue with naming the value returned by useValueWithTimezone
is that we have the values that are stored in the state (the other usages of useValueWithTimezone
don't have this issue), so the value returned by useValueWithTimezone
is still not the value the we should use for most of the usages.
So I'd prefer to keep some information on the variable returned by useValueWithTimezone
saying that it's still an "input" value.
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 have so many values in this hook 😆
props.value
props.defaultValue
- the value returned by
useValueWithTimezone
dateState.draft
dateState.lastPublishedValue
dateState.lastComittedValue
dateState.lastControlledValue
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.
Ok, if you feel that it improves the clarity, let's go with that approach. 👌
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.
Alternatively I can rename inValueWithRenderTimezone
into inValue
since it's the one we use as "props.value" in 90% of the file
Deploy preview: https://deploy-preview-13481--material-ui-x.netlify.app/ |
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.
Nice! 🎉
It's awesome to see that this was just a small oversight after all. 🙌
WDYT, would still adding at least a test or two make sense? 🤔
@@ -165,19 +165,31 @@ export const usePickerValue = < | |||
const { | |||
onAccept, | |||
onChange, | |||
value: inValue, | |||
value: 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.
Do you think that having inValue
and inValueWithTimezone
would not be enough? 🤔
Or even as we have everywhere else: inValue
and value
for the value returned from useValueWithTimezone
..? 🤔
I added one very basic test that reproduces the issue 👍 |
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.
Great work, thank you! 🙏 🎉
… layout components (mui#13481)
… layout components (mui#13481)
Fixes #13319
Looks like the fix is easier than expected
All the tests are passing, for me this is fixing the root issue since
usePickerValue
returns the value that will be used in all the pieces of the picker.I first tried to pass the
timezone
to theToolbar
, but it's quite fragile since we could have the exact same problem in other parts of the UI (the shortcuts for instance).