React-day-picker: <DayPickerInput /> choosing selected date erases value

Created on 13 Jun 2017  路  12Comments  路  Source: gpbl/react-day-picker

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

All 12 comments

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

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?

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.

I've added a prop clickUnselectsDay to enable this feature 馃憤

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

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

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

@yashsharma04 please share your code, thanks!

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

@jimniels did you manage to resolve this?

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

Thanks, @jimniels, I will give it a try

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vulcanoidlogic picture vulcanoidlogic  路  6Comments

mcapodici picture mcapodici  路  3Comments

matfork-belatrix picture matfork-belatrix  路  5Comments

NikitaSasin picture NikitaSasin  路  5Comments

magnusohlin picture magnusohlin  路  4Comments