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

SingleDatePicker: startDate and endDate passed to onClose when clicking outside #1674

Open
mauricesnip opened this issue Jun 6, 2019 · 5 comments
Labels
bug Oh no, something's broken :-( pull request wanted This is a great way to contribute! Help us out :-D

Comments

@mauricesnip
Copy link

react-dates@20.2.0

While implementing the SingleDatePicker I found out that onDayClick passes { date: Moment } and onOutsideClick passes { startDate: undefined, endDate: undefined } to onClose. See: https://github.com/airbnb/react-dates/blob/11de2016bf6e7111ddebd5a7f7fc1fe929a3600c/src/components/SingleDatePicker.jsx#L206

Should the latter even be the case for SingleDatePicker, since there's only one date?

@ljharb
Copy link
Member

ljharb commented Jun 6, 2019

This is a bug, since those two aren't props of the SDP.

These should be removed, and date should be passed instead.

@ljharb ljharb added bug Oh no, something's broken :-( pull request wanted This is a great way to contribute! Help us out :-D labels Jun 6, 2019
@AlokTakshak
Copy link
Contributor

@ljharb i would like to work on that , we need to remove startDate and endDate and pass only date to onClose right?

@ljharb
Copy link
Member

ljharb commented Jun 7, 2019

Yes. Since they were only ever passed as undefined, it shouldn’t be a breaking change.

@AlokTakshak
Copy link
Contributor

#1678

@manuelurenah
Copy link

My work around for this issue:

<SingleDatePicker
  // ...
  onClose={date => {
    const parsed = JSON.parse(JSON.stringify(date));
    // Your date is at parsed.date
  }}
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Oh no, something's broken :-( pull request wanted This is a great way to contribute! Help us out :-D
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants