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

Unselect / Clear #211

Open
hlarcher opened this issue Mar 25, 2019 · 3 comments
Open

Unselect / Clear #211

hlarcher opened this issue Mar 25, 2019 · 3 comments

Comments

@hlarcher
Copy link

Is there a way to unselect / clear the date range selection?

I've tried with a custom button that sets the value in state to null and then pass that value to the value prop but it makes the browser unresponsive without yielding any errors.

@hlarcher
Copy link
Author

hlarcher commented Mar 26, 2019

If I pause in DevTools here is where the script is unresponsive (line 24 of calendar.js):

Calendar.prototype = { constructor: Calendar, weekStartDate: function weekStartDate(date) { var startDate = new Date(date.getTime()); // <---- startDate = Invalid Date {}

@jsmrcaga
Copy link

jsmrcaga commented May 4, 2019

I'm experiencing the exact same issue. For now I'm going to re-render the whole parent component as to recreate the date range picker state.

@hlarcher to do it i'm just adding a key prop to my <DateRangePicker set to a random value between state changes (I added a render state and set it to render: this.state.render + 1 each time i want to reset the picker)

It's a great range picker, keep up the good job!

@Pawel-Janik
Copy link

Pawel-Janik commented Jan 30, 2020

This supposed to be fixed in #190 but the fix doesn't cover the scenario when no initialYear and initialMonth is specified. I've set up both of them to values that are outside possible data range and the picker works as expected.

<Button onClick={() => this.onExpirationDateChange(null)}>reset</Button>
<DateRangePicker
    minimumDate={moment().startOf('day').toDate()}
    selectionType="single"
    value={this.state.expirationDateDay}
    onSelect={this.onExpirationDateChange}
    initialYear={moment().startOf('day').year()}
    initialMonth={moment().startOf('day').month()}
/>

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

3 participants