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

<DayPickerInput /> choosing selected date erases value #399

Closed
jimniels opened this issue Jun 13, 2017 · 12 comments
Closed

<DayPickerInput /> choosing selected date erases value #399

jimniels opened this issue Jun 13, 2017 · 12 comments
Milestone

Comments

@jimniels
Copy link

To reproduce this bug, simply use the live <DayPickerInput /> example

  1. Choose a date
  2. Now choose the same date
  3. Note how the currently selected value gets cleared

example

@gpbl
Copy link
Owner

gpbl commented Jun 13, 2017

Yup this is working as expected - doesn't for you?

@jimniels
Copy link
Author

Yup this is working as expected

When you say that, do you mean that if you select a date, then click on that exact same date, you expect that the value of the input gets reset? That's not expected behavior to me. If I click on a date that's already selected, I would expect it to just stay the same

How I would expect it to work:

  1. Input is empty initially
  2. Click on the input to reveal calendar
  3. Select a date, i.e. "June 14, 2017"
  4. Calendar disappears and input gets populated with date "June 14, 2017"
  5. Click on input again to reveal calendar
  6. Select the same date as step 3, i.e. "June 14, 2017"
  7. Calendar disappears and input stays populated with date "June 14, 2017"

How it's working currently (for me):

  1. Input is empty initially
  2. Click on the input to reveal calendar
  3. Select a date, i.e. "June 14, 2017"
  4. Calendar disappears and input gets populated with date "June 14, 2017"
  5. Click on input again to reveal calendar
  6. Select the same date as step 3, i.e. "June 14, 2017"
  7. Calendar disappears and input gets reset to empty value ""

Note how these steps are the exact same except for step 7. The date picker seems to work according to the following human/computer interaction: "click on a date to populate the input". It doesn't care what the currently selected date is. It doesn't care what date you're selecting. Could be tomorrow, could be yesterday, could be 50 years in the future, could be 50 years in the past, could be today. Whatever day you choose, that day gets populated in the input.

Does it seem odd to you that, in this case, clicking on a day in the calendar empties the value of the input rather than fills it?

@gpbl
Copy link
Owner

gpbl commented Jun 13, 2017

i see what you mean ! The original idea is to click to select a day and click again to deselect it, thus clearing the field.

I agree it doesn't make much sense as this behavior could be added by the implementer.

@gpbl gpbl added this to the v5.6.0 milestone Jun 14, 2017
@gpbl gpbl closed this as completed in #411 Jun 16, 2017
@gpbl
Copy link
Owner

gpbl commented Jun 16, 2017

I've added a prop clickUnselectsDay to enable this feature 👍

@yashsharma04
Copy link

yashsharma04 commented Sep 30, 2017

clickUnselectsDay = {false} .this doesn't work for me !

@gpbl
Copy link
Owner

gpbl commented Sep 30, 2017

@yashsharma04 please replicate your issue here https://codesandbox.io/s/XDAE3x0W8
thanks!

@yashsharma04
Copy link

@gpbl it happens for me , but doesn't happen here https://codesandbox.io/s/XDAE3x0W8

@gpbl
Copy link
Owner

gpbl commented Oct 1, 2017

@yashsharma04 please share your code, thanks!

@amit-nautiyal-crs
Copy link

@yashsharma04 did you manage to fix this issue. I am stuck on same bit

@amit-nautiyal-crs
Copy link

@jimniels did you manage to resolve this?

@jimniels
Copy link
Author

@amit-nautiyal-crs I'm on the latest version (7.3.0) and it's fixed there.

@amit-nautiyal-crs
Copy link

Thanks, @jimniels, I will give it a try

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

4 participants