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

chosenLabel property is not reset on new apply event and stores value of previous selection #120

Closed
wzup opened this issue Jan 27, 2017 · 2 comments

Comments

@wzup
Copy link

wzup commented Jan 27, 2017

How to reset chosenLabel on every new apply event?

Here is a use case.

Given DateRangePicker settings for reset range:

<DatePicker
    id="actDate"
    startDate={moment()}
    endDate={moment()}
    dateLimit={null}
    onEvent={this.onEvent}
    ranges={{
        'Tomorrow': [
            moment().add(1, 'day'),
            moment().add(1, 'day')
        ],
        'Next 15 Days': [ ... ],
        'This Month': [ ... ],
        'Next Month': [ ... ],
        'RESET': [ ... ]
    }}
/>

And onEvent method looks like this. Look at picker.chosenLabel.toLowerCase() line:

onEvent = (ev, picker) => {
    if(ev.type == 'show' || ev.type == 'hide') return;
    let reset = false;
    if(picker.chosenLabel.toLowerCase() == 'reset') {    <== here
        reset = {reset: true}
    }
    this.props.dispatch(sortByDate(reset))
}

Ranges:

ranges - google chrome 2017-01-27 17 36 36

Steps to reproduce the issue:

  1. Click any predefined ranges after the datepicker loaded. Suppose it was RESET.
  2. Now make a custom selection of date. You will see that chosenLabel equals RESET. The property for some reason stores the value from previous selection. It is not logical. I'm making a brand new custom range selection, but the property is equal previous selection. This is what I don't expect and my code on custom date selection gives wrong result because of that.

chosenlabel - google chrome 2017-01-27 16 53 30

How to reset chosenLabel on every new apply event? Or at least how to set chosenLabel to null on custom range selection, so that it is reset from previous value?
Or even more specifically:
How to figure out that a custom date range is selected at the moment, not a preset? Because as you just saw, checking chosenLabel gives wrong result.

@wzup wzup changed the title Missing chosenLabel property in production after code uglify chosenLabel property is null in production after code uglify Jan 27, 2017
@wzup wzup changed the title chosenLabel property is null in production after code uglify chosenLabel property becomes null in production after code uglify Jan 27, 2017
@wzup wzup changed the title chosenLabel property becomes null in production after code uglify chosenLabel property is not reset on new apply event and stores value of previous selection Jan 27, 2017
@skratchdot
Copy link
Owner

closing this due to inactivity. please re-open if this is still an issue in v6.0.0 or greater

@piddubetskyy
Copy link

Still not resetting to previously chosen value on cancel

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