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

Calendar does not change when dates are changed via input #1845

Open
andrheapaltao opened this issue Oct 22, 2019 · 10 comments
Open

Calendar does not change when dates are changed via input #1845

andrheapaltao opened this issue Oct 22, 2019 · 10 comments

Comments

@andrheapaltao
Copy link

As the topic says, the calendar does not switch to the date entered via input box. I have tried it with the demos in storybook: Allow All Days Including Past Days

First enter: 10/25/2019 in startDate
image
You'll see it is highlighted in the calendar.

2nd: 10/25/2018
image

3rd: 10/25/2025
image

As you can see in the 2nd and 3rd input, it does not render the calendar on those years. In order to see the change in calendar, you need to enter start and end date and close the calendar. Right now I am using the ff. settings:

<DateRangePicker
        startDateId="startDate"
        endDateId="endDate"
        startDate={start}
        endDate={end}
        daySize={25}
        onDatesChange={({ startDate, endDate }) => {
          setStateStartDate(startDate);
          setStateEndDate(endDate);
        }}
        focusedInput={focusedInput}
        onFocusChange={focused => {
          if (focused) {
            setStatefocusedInput(focused);
          }
        }}
        keepOpenOnDateSelect
        autoFocus={() => true}
        hideKeyboardShortcutsPanel
        noBorder
        isOutsideRange={() => false}
        customArrowIcon={<i className="fa fa-long-arrow-right ml-2" />}
        numberOfMonths={2}
        showDefaultInputIcon
        inputIconPosition="after"
      />

I am using the keepOpenOnDateSelect for UI/UX purposes.
Question is: How can I re-render the calendar without closing the calendar itself? Is it possible to re-render the calendar upon finished typing?

Also I think it is a bug when isOutsideRange false, the past dates that were selected aren't highlighted. They'll only be highlighted when switching months and they'll be gone when you focus on the month of the date specified. Found this Past Issue with no solution. Is there any solution now?

The demo isn't enough to cover all of the props of the datepicker. I hope there will be more examples on how to properly use the props. Thank you very much in advance.

@andrheapaltao andrheapaltao changed the title Calendar does not changed when dates are changed via input Calendar does not change when dates are changed via input Oct 22, 2019
@pompan129
Copy link

pompan129 commented Apr 19, 2020

any progress on this? I'm having the same problem. onDatesChange is called but with null values.

@AlbertoTonegari
Copy link

Hello! 👋
Any progress on this? I am unable to update the calendar date when I type the date from the input in the SingleDatePicker. The calendar updates with the date specified in the input, but in doesn't go automatically to that date. Is there a way to get the following behaviour:

  • write the date in the input field and the caledar automatically takes you to that date, whithout the need of clicking the arrows.

An answer will be greatly appreciated.
Thanks a lot!

@kiddailey
Copy link

This may be a separate issue, but it feels related. It also doesn't seem to update if you pass startDate or initialVisibleMonth as props and later update those props outside of the component. In other words, through state changes on the parent component. Seems like something is preventing it from seeing the updated dates.

@daniellesuper
Copy link

if i understand the issue correctly, i had a similar issue. i was passing an array of objects in that contained the dates i needed highlighted. this array changed in length based on filters that were selected. the calendar would only highlight the initial array of dates passed in, it wouldnt change when the filters values changed. heres what i did to resolve, hope it helps

componentDidUpdate(prevProps: Readonly<any>): void { if (prevProps.calendarEvents.length !== this.props.calendarEvents.length){ if (this.state.focused === null) { this.setState({focused: undefined, date: null}); } else { this.setState({focused: null, date: null}); } } }

@nitish-arora
Copy link

Any progress on this? I want to update the dates from outside of calendar and calendar will always in open state.

When I updated the date from outside of the calendar, calendar remained at that month.

@TheHuns
Copy link

TheHuns commented Jan 26, 2022

Also curious if anyone has found a solution for this. Not a deal breaker as this is the best (most customizable) date picker I have found, but this would be the last thing needed to make it feel truly complete.

@ljharb
Copy link
Member

ljharb commented Jan 26, 2022

If there's a solution that can be added to the docs, great! Please submit a PR.

If there's a solution that requires changes to this library, please submit a PR (ideally after some discussion here).

@nitish-arora
Copy link

nitish-arora commented Jan 27, 2022 via email

@bruno-naibert

This comment was marked as spam.

@angenue
Copy link

angenue commented Oct 17, 2023

setting an activeStartDate worked for me

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

10 participants