-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Fix DateInput and DateTimeInput Do Not Handle Temporary Values Correctly #9543
Conversation
355d240
to
f6e2760
Compare
} | ||
}, [setRenderCount, parse, field]); | ||
|
||
const { onBlur: onBlurFromField } = field; |
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.
Why have a different logic for onBlur
and onFocus
?
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.
react-hook-form only handle onBlur
not onFocus
and it will call any custom onBlur
provided
const renderHelperText = | ||
helperText !== false || ((isTouched || isSubmitted) && invalid); | ||
|
||
const { ref, name } = field; | ||
|
||
console.log('field', field); |
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.
console.log
spotted
@@ -133,7 +211,8 @@ const getStringFromDate = (value: string | Date) => { | |||
// null, undefined and empty string values should not go through dateFormatter | |||
// otherwise, it returns undefined and will make the input an uncontrolled one. | |||
if (value == null || value === '') { | |||
return ''; | |||
console.log('toto'); |
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.
console.log
spotted
return ( | ||
<TextField | ||
id={id} | ||
{...field} |
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.
Why remove {...field}
?
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.
Because the input is fully controlled locally now
I'm afraid you brought a regression to the Capture.video.2024-01-04.11.52.30.mp4 |
Fix #9330
The final implementation works in all tested browsers and handle reset correctly. However,
required
validation won't work when the form mode is set toonChange
. The validation message will only be displayed when the input is blurred.