React-date-picker: Auto close picker after selecting month or year?

Created on 10 Sep 2018  路  2Comments  路  Source: wojtekmaj/react-date-picker

Is there any way to auto close picker after selecting year or month? I am using 'decade' view and 'year' view to only select Year or Month from picker. And after selcting it picker should close as per my requirement.
Ex. Currenlty i am selecting an year and closing it manually. Then again if i want to change year then it is going into months sections of previosuly selected year. I want to prevent that.

Here is for Year View.

<DatePicker 
value={this.state.selectedYear} 
onClickYear = {(value) => this.setState({ selectedYear: value })}
view="decade"
/> 

Here is for Month View

<DatePicker 
value={this.state.selectedMonth} 
onClickMonth = {(value) => this.setState({ selectedMonth: value })}
view="year"
/> 
question

Most helpful comment

You could use maxDetail="year" to keep the user from entering the month view. This way you will only select a month, not a specific day in it.

All 2 comments

You could use maxDetail="year" to keep the user from entering the month view. This way you will only select a month, not a specific day in it.

Thanks. I found this property in documentation after your comment. I think sometimes it is difficult to understand explanation as per requirement even if what we are looking for is right there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aladinflux picture aladinflux  路  3Comments

FrontendLead picture FrontendLead  路  8Comments

vanmanh49 picture vanmanh49  路  4Comments

RubberChickenParadise picture RubberChickenParadise  路  6Comments

leo-iomer picture leo-iomer  路  8Comments