[pickers] Allow custom fields to validate the value#14486
Merged
flaviendelangle merged 17 commits intomui:masterfrom Sep 11, 2024
Merged
[pickers] Allow custom fields to validate the value#14486flaviendelangle merged 17 commits intomui:masterfrom
flaviendelangle merged 17 commits intomui:masterfrom
Conversation
96e2c3b to
d0070e1
Compare
|
Deploy preview: https://deploy-preview-14486--material-ui-x.netlify.app/ Updated pages: |
d0070e1 to
c312072
Compare
18b2e88 to
2765a2e
Compare
aed4748 to
0653dc3
Compare
0653dc3 to
db2fbcc
Compare
b095b86 to
f93a7be
Compare
f93a7be to
80162f2
Compare
59f49be to
75f943e
Compare
75f943e to
d2405b3
Compare
d47cf7a to
0b4c4a1
Compare
4 tasks
Contributor
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
LukasTy
approved these changes
Sep 11, 2024
Member
LukasTy
left a comment
There was a problem hiding this comment.
Great work! 👍
This is a masive improvement! 💙 💯
The new custom field DX looks awesome. 🙌
Merged
2 tasks
3 tasks
arthurbalduini
pushed a commit
to arthurbalduini/mui-x
that referenced
this pull request
Sep 30, 2024
This was referenced Oct 5, 2024
This was referenced Oct 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14495
Changes
useValidationisSameErroranddefaultErrorStatetouseValidation, instead bind thevalueManagerdirection to thevalidator(when usingvalidateTime, we always need theisSameErroranddefaultErrorStateof thesingleItemValueManagertimezone, thevalueand theonChangeoutside of thepropsobject passed to theuseValidationhook. We often override these properties (because we don't want the one in the prop, we want the one with a default value, the one of the internal state, etc...), we were often doingprops: { ...props, timezone, value: state.value }which was very error prone. Nowpropsonly contains the validation props (minDate, ...), we could even consider renaming it.useValidation(hasValidationErrorandgetValidationErrorForNewValue) to make sure that people never needutilsorvalueManagerto manage their error,useValidationshould be sufficient.Field components
DateFieldInPickerProps,TimeFieldInPickerProps, etc... interfaces that simplifies dramatically how to type custom fields. They contain the props the field actually receives from the picker.New DX
And if you want to
Demo
Extracted PRs
onErrorJSDoc #14492useSplitFieldPropsand make it public #14514Follow up