Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

gorbeia
Copy link

@gorbeia gorbeia commented Sep 18, 2020

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.

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.
Copy link

@kevinpapst kevinpapst left a 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()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (start != null && !start.isValid()) {
if (start !== null && !start.isValid()) {

if (start != null && !start.isValid()) {
start = null;
}
if (end != null && !end.isValid()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (end != null && !end.isValid()) {
if (end !== null && !end.isValid()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants