-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[fields] Allow to explicitly define the reference date and improve its default value #9019
[fields] Allow to explicitly define the reference date and improve its default value #9019
Conversation
referenceValue
and improve its default value
d3b6ad0
to
1ddb568
Compare
Netlify deploy previewNetlify deploy preview: https://deploy-preview-9019--material-ui-x.netlify.app/ Updated pagesThese are the results for the performance tests:
|
7e8063e
to
f7a2f5b
Compare
f7a2f5b
to
9e9b109
Compare
6ef3908
to
753cb01
Compare
753cb01
to
f29cf97
Compare
referenceValue
and improve its default value95588cb
to
2555489
Compare
2555489
to
77f1182
Compare
packages/x-date-pickers-pro/src/MultiInputDateRangeField/MultiInputDateRangeField.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers-pro/src/internal/utils/valueManagers.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/utils/getDefaultReferenceDate.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/utils/getDefaultReferenceDate.ts
Outdated
Show resolved
Hide resolved
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.
From a limited amount of testing it looks like a really nice improvement! 👍 💯
Have you considered having referenceDate
exposed top-level via pickers as well? Or do you want to firstly release it available only on fields for testing and only later add it to pickers if everything is smooth? 🤔
packages/x-date-pickers/src/DateTimeField/tests/editing.DateTimeField.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/DateTimeField/tests/editing.DateTimeField.test.tsx
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/useField/useField.types.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/useField/useField.types.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/useField/useField.types.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.types.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/hooks/usePicker/usePickerValue.types.ts
Outdated
Show resolved
Hide resolved
packages/x-date-pickers/src/internals/utils/getDefaultReferenceDate.ts
Outdated
Show resolved
Hide resolved
Yes, I'm splitting the work in two, but the goal is to release it on the pickers as well. |
Closes #8311
Closes #9023
Introducing the same prop on the pickers would solve the following issues:
<MonthCalendar />
#8852Part of #8426 (starts to introduce the ms methods on the adapters)
Goal 1: Smartly handle the
referenceValue
based on the validation propsWhen a field does not contain all the sections it could have (e.g: a
DateField
with no year), people can be stuck with an invalid value and not be able to fix it because the invalid part is not present in the format.Goal 2: Smartly handle the
referenceValue
based on the sections presentWhen a field does not contain some more precise sections (e.g: a field without a
seconds
sections), we don't want to take the sections of today's date.The sections with a higher granularity than the format should be set to 0 instead of the current value.
Goal 3: Allow user the set a custom
referenceValue
with the newreferenceDate
propThe main use case I see is how to set the date the 1st filled value should have on a
TimeField
when there is notvalue
/defaultValue
.referenceDate
prop on fieldsreferenceValue
based on validationreferenceValue
based on the sections extracted from the formatFollow up
referenceValue
prop on pickers, compute it's value based on the views and the validation propsdefaultCalendarMonth
withreferenceValue
(keep the old one but deprecate)