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

[DateInput][RangeCalendar] Blurring the date input will reset the date unexpectedly #646

Open
BionBit opened this issue Dec 2, 2019 · 0 comments

Comments

@BionBit
Copy link

BionBit commented Dec 2, 2019

Switching between left-right side calendar date inputs will reset the endValue unexpectedly in some cases.

STR:

  1. Open the range calendar
  2. Notice the date range, for example, Dec 2 - Jan 2
  3. Click on the end date input
  4. Click on the start date input
  5. Notice that the end date input resets to Dec 2019, when it should be Jan 2020

Cause,

  • Reading from 'selectedValue' is the latest value.
  • Although the 'str' state gets updated in getDeritvedState, it doesn't always happen for some reason.

Proposed fix (tested locally), DateInput.js

onBlur = () => {
  this.setState((prevState, prevProps) => ({
    hasFocus: false,
    - str: formatDate(prevProps.value, prevProps.format),
    + str: formatDate(prevProps.selectedValue, prevProps.format),
    + invalid: false
  }));
}
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

1 participant