-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[fields] Always use props.value
as the source of truth when defined
#15875
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] Always use props.value
as the source of truth when defined
#15875
Conversation
Deploy preview: https://deploy-preview-15875--material-ui-x.netlify.app/ Updated pages: |
props.value
as the source of truth when defined
169db6a
to
4c89824
Compare
As you said, the only value I see in the invalid date is for people that want to differentiate an empty date and a partially filled date. |
Yes, thoroughly re-checking the code and thinking about it more, I've come to a similar conclusion. 👌 |
|
@LukasTy the PR is updated and the test are passing 🙏 |
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, but I think we could still have one "undefined" case:
- enter any valid value
- copy year section value
- move to month or day section and paste the copied value
Currently this would trigger an error state with invalidDate
validation.
On this PR we no longer have the error state and the onError
callback returns null null
as if there is no value and no error, but the field keeps the invalid section values. 🙈
Screen.Recording.2025-03-04.at.10.30.16.mov
This leads me to another question - what about the invalidDate
validation?
Does/would it still make sense after this change? 🤔
People can still be invalid date from the outside. I'll check the regression you're describing 👍 |
@LukasTy I did not handle fully-filled but invalid dates correctly.
Note: the browser input does not support copy pasting at all from what I can see, so we can't take inspiration there. |
3a5cb50
to
0e28813
Compare
0e28813
to
37a5396
Compare
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 did not handle fully-filled but invalid dates correctly. For me we have two ways of handling it:
- We refuse the update (the section does not update)
- We fire an invalid date
Note: the browser input does not support copy pasting at all from what I can see, so we can't take inspiration there. Imo, firing an invalid date is the best solution here.
I think that your chosen behavior makes a lot of sense. 👍
That's also what we do currently, so, it will minimize the amount of breaking behaviors. 🙌
Could we add a migration page entry and a changelog in the PR comment? 🤔
@LukasTy I added a small migration guide 👍 |
bbb3dcd
to
4a57299
Compare
docs/data/migration/migration-pickers-v7/migration-pickers-v7.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Lukas Tyla <[email protected]> Signed-off-by: Flavien DELANGLE <[email protected]>
Part of #15530
We should now have a behavior coherent with the browser input and working well on range inputs as well.
Not sure if we should count that purely as a bug fix or as a breaking change.
Follow up
props.value
as the source of truth inusePickerValue
(should be a lot simpler)