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 · 8 comments

Comments

3 participants
@jimniels

jimniels commented Jun 13, 2017

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

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Jun 13, 2017

Owner

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

Owner

gpbl commented Jun 13, 2017

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

@jimniels

This comment has been minimized.

Show comment
Hide comment
@jimniels

jimniels Jun 13, 2017

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?

jimniels commented Jun 13, 2017

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

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Jun 13, 2017

Owner

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.

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 in #411 Jun 16, 2017

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Jun 16, 2017

Owner

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

Owner

gpbl commented Jun 16, 2017

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

@yashsharma04

This comment has been minimized.

Show comment
Hide comment
@yashsharma04

yashsharma04 Sep 30, 2017

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

yashsharma04 commented Sep 30, 2017

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

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Sep 30, 2017

Owner

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

Owner

gpbl commented Sep 30, 2017

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

@yashsharma04

This comment has been minimized.

Show comment
Hide comment
@yashsharma04

yashsharma04 Oct 1, 2017

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

yashsharma04 commented Oct 1, 2017

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

@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Oct 1, 2017

Owner

@yashsharma04 please share your code, thanks!

Owner

gpbl commented Oct 1, 2017

@yashsharma04 please share your code, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment