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

Date Range Picker not working properly when try to edit directly on input box #4002

Open
lechu24 opened this issue Apr 18, 2023 · 6 comments
Labels

Comments

@lechu24
Copy link

lechu24 commented Apr 18, 2023

Describe the bug
When I try to edit the dates in date range picker directly in the input box without using the range picker the start date and end date is not getting updated rather it is getting reseted to old values.

To Reproduce

  1. Go to date range picker
  2. Select a date range (ex: 02/11/2023 - 15/12/2023)
  3. Now try to edit the date directly on the input box (example change the end date from 15/12/2023 to 18/12/2024)
  4. You will see that the date will not get updated it will be reseted again to 15/12/2023.

Expected behavior
It should change to 18/12/2024.
The expected behaviour is that the date should change even when we directly change that in the input box without changing it through date range picker

Screenshots
1.image

image

image

image

@aziyatali
Copy link

@lechu24 That's because you are passing selected props startDate
And your startDate is new Date which is current date.

Try something like this and make sure you are selecting both date when props change.

<DatePicker
        dateFormat={dateFormat}
        locale={chosenLocale}
        selected={startDate}
        startDate={startDate}
        endDate={endDate}
        onChange={(date) => setStartDate(date)}
      />

    <DatePicker
      dateFormat={dateFormat}
      locale={chosenLocale}
      selected={endDate}
      onChange={(date) => {
        console.log(date);
        setEndDate(date);
      }}
    />

Copy link

github-actions bot commented Jun 2, 2024

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jun 2, 2024
@rickysandoval
Copy link

@aziyatali that's not really an answer. Your snippet if for a separate solution: using two date pickers to make a range.

The issue is with using the selectsRange prop. When using that prop you cannot set or change the entire range using the input. If you type in dates it'll set the start date but it won't recognize any further input past that.

@rickysandoval
Copy link

Also having this issue btw

@mats363
Copy link

mats363 commented Aug 9, 2024

I have the same issue. Seems like the problem is parsing logic preventing onChange from running unless it's a valid single date. Probably around here

Screenshot with a console.log after typing in the input field.

(

let date = parseDate(
)
Screenshot 2024-08-09 at 16 09 20

Any ideas?

@laug
Copy link
Contributor

laug commented Aug 15, 2024

See also #3596 and #3906 which report the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants