-
Notifications
You must be signed in to change notification settings - Fork 3.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
Ignore invalid data from input #2152
base: master
Are you sure you want to change the base?
Conversation
When original data in the input is not valid moment.js creates a date object but it is invalid. DateRangePicker then shows the month view filled of NaNs. This change makes DateRangePicker to ignore the input data if it can´t be properly parsed.
But keep in mind that they can be already null.
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 have suffered from that bug as well, so I like the solution 👍
Just a minor suggestion to use type safe null safe check
@@ -304,6 +304,12 @@ | |||
start = moment(val, this.locale.format); | |||
end = moment(val, this.locale.format); | |||
} | |||
if (start != null && !start.isValid()) { |
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 (start != null && !start.isValid()) { | |
if (start !== null && !start.isValid()) { |
if (start != null && !start.isValid()) { | ||
start = null; | ||
} | ||
if (end != null && !end.isValid()) { |
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 (end != null && !end.isValid()) { | |
if (end !== null && !end.isValid()) { |
When original data in the input is not valid moment.js creates a date object but it is invalid. DateRangePicker then shows the month view filled of NaNs. This change makes DateRangePicker to ignore the input data if it can´t be properly parsed.