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

Any way to know if i select the start or the end of my range date? #202

Closed
JohnCoding94 opened this issue May 19, 2018 · 4 comments
Closed
Labels

Comments

@JohnCoding94
Copy link

Hi,

First, thanks for this great module :)

I would like to hide the component when a range date has been selected (keeping it open feels like a bug).

So in the onChange callback, i was expecting some information about the context (let's say something like context=startDate|endDate|actionButton), so if context is different from 'startDate' i keep it displayed, otherwise, i hide it.

Maybe there is already another way to implement that classic behavior?

@mkg0
Copy link
Collaborator

mkg0 commented May 23, 2018

Hi @JohnCoding94

Normally react-date-range controls focused range itself by the way you can control it them with focusedRange and onRangeFocusChange props. If you control it you can is it start date or end date like below.

<DateRangePicker
{...props}
focusedRange={this.state.focusedRange}
onRangeFocusChange={focusedRange=>{
const [rangeIndex, rangeStep] = focusedRange;
if(rangeStep === 0){
    console.log('start date');
} else {
    console.log('end date');
}

// also don't forget to set focused range
this.setState({focusedRange});
}}
/>

@mkg0 mkg0 closed this as completed May 23, 2018
@mkg0
Copy link
Collaborator

mkg0 commented May 23, 2018

Feel free to ask anything if you stuck related to this topic 🙂

@mkg0 mkg0 added the question label May 23, 2018
@kesha-antonov
Copy link

@mkg0 Thanks!

@kesha-antonov
Copy link

screen shot 2018-08-23 at 20 24 06

Maybe it's error
When I select first date - I get [0,1]
When I select second date - I get [0,0]

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

3 participants