-
Notifications
You must be signed in to change notification settings - Fork 175
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
[Core] Date field js validation #7266
Conversation
Why is this going to 23? |
I'm using v23 in the project I implemented this for. |
onUserInput: PropTypes.func, | ||
}; | ||
|
||
DateElement.defaultProps = { | ||
name: '', | ||
label: '', | ||
value: '', | ||
value: undefined, |
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.
@laemtl should value be undefined? Line 1054 still checks this.props.value === ''
for if empty string. I'm wondering if null is more appropriate instead of undefined if empty string isn't preferred for some reason?
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.
If the value is set to '', an error is detected on page load (the initial value enters the error test case on line 1054). Value can be null instead, but other elements (select for example) use undefined as their initial value. Any reason why undefined should be avoided?
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've not witnessed undefined from an input tag before and so I was just curious. I get an empty string when the variable has not been set for <input>
if I make one and try to console.log the value. I'm guessing date works differently.
@laemtl I have changed the base on github from 23 to main so this PR stops showing up when we query the 23 branch. The PR now shows a bunch of files changed/commits/conflicts. dont worry about these for now, as soon as we puch 23 into main (after the release) they should auto resolve and if not a minor rebase should do the trick. |
@laemtl can you rebase this? It's both showing the wrong changes since it was originally sent to a different branch and needs to have the tests run on php8. |
@laemtl could you rebase the PR please? Thank you! |
87f2676
to
466e103
Compare
@cmadjar Rebased. |
@laemtl the diff looks better now but it looks like the tests are failing since rebasing |
466e103
to
3d34ec5
Compare
@driusan ready for you :) |
For one of my projects, I need to validate a date field in React and display a front-end error message. Select fields have an errorMessage and hasError prop for such scenarios, but those are not implemented on DateElement. This PR implements the same logic on DateElement.