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

onDayChange not always called from DayPickerInput #614

Closed
mcapodici opened this issue Jan 24, 2018 · 3 comments
Closed

onDayChange not always called from DayPickerInput #614

mcapodici opened this issue Jan 24, 2018 · 3 comments
Milestone

Comments

@mcapodici
Copy link

The onDayChange function is not called where you manually enter invalid text into the text box of the DayPickerInput.

See https://codesandbox.io/s/v6m53q7o47

Select a date - alert is shown

Enter X as the date picker text - no alert

@mcapodici
Copy link
Author

mcapodici commented Jan 25, 2018

In daypickerinput.js it has

      if (onDayChange) {
        onDayChange(undefined, {});
      }
      return;
    }
    const day = parseDate(value, format, dayPickerProps.locale);
    if (!day) {
      this.setState({ value });
      return;
    }
    this.updateState(day, value);

perhaps the if(!day) { ... } statement should also call onDayChanged passing in undefined.

@paulcredmond
Copy link

onDayChange only runs if a day is selected from the calendar, but I have the same issue with firing an event from the input. The standard onBlur or onChange events don't run when input text is manually entered. Am I missing something here? I need to be able to validate the input from this field if a user ignores a selection on the calendar but enters invalid text in the input.

@paulcredmond
Copy link

I was missing something, input props that you can pass:

inputProps={{ onChange: this.handleInputChange, onBlur: this.handleInputBlur }}

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

No branches or pull requests

3 participants