-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
DatePicker: isRequired validation bug #822
Comments
@fantua |
@gitjain http://codepen.io/fant/pen/bqzBZd enter something into the input. |
@fantua, we're cleaning up old issues that haven't had traction on them in awhile--please feel free to reopen if this is still an issue. @johannao76, since your team owns DatePicker, can you take a look at this and see if this still needs to be addressed? |
Sure! @johannao76, any chance you or someone from your team could take a look at this when you have a chance? |
taking a look |
It looks like since we allow DatePicker to have the value passed as a property, there was some additional logic added to make sure that validation was run during componentWillReceiveProps. However, that fires every rerender (after initial render), and validation was running even though none of the props had actually changed. I added a quick check at the top to make sure the validation doesn't run unless props actually changed, and that appears to fix this issue. |
@lorejoh12 Thanks for looking at this. But this behavior is still different from other components, like Dropdown and TextField. Rerendering doesn't fire other components(with required=true, and they also accept value passed as a property), so is this inconsistent? Can we make them consistent? |
Hmm, I find that TextField NEVER fires even if 1) the value change from non-empty to empty, 2) focus in the field and blur without entering text. TextField only fires when there is error message. |
I'm not sure I understand what you're referring to by "fires". By fires, I'm referring to the validate method ever being called. TextField certainly fires "componentWillReceiveProps", which checks if value changed and fires delayedValidate, which then fires validate method. This is only one of the ways in which validate gets fired, but it's the one that's broken in DatePicker right now. DatePicker currently fires validate without checking if the value actually changed. My updated PR will check that one of the properties we care about changed now before doing any validation, which means we'll get consistent behavior with TextField once this goes in. |
Here, we mean the boarder changes to red. |
Bug Report
Describe the issue:
Create form with TextField and DatePicker components. TextField is controlled component (by value and onChanged), so when typing some data to him - React will re-render form.
Actual behavior:
After re-render validation is fired.
Expected behavior:
Validation should fired only when DatePicker loses focus.
Additional question:
How check is DatePicker valid when form is submitting?
Perhaps better will be also add required prop to DatePicker input element this will prevent form submitting when DatePicker is empty?
The text was updated successfully, but these errors were encountered: