react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Year dropdown should not show years after the max date or before the min date.

Open jbccollins opened this issue 10 years ago • 4 comments

If a min/max date is specified then the year dropdown should respect those min/max dates and not allow the user to pick years that are outside of the min/max range.

jbccollins avatar Nov 29 '16 20:11 jbccollins

I will make a PR for this

jackhamburger avatar Jan 11 '17 23:01 jackhamburger

Ok somewhere between 0.33.0 and 0.41.1 this has been fixed. Whether intentionally or incidentally I'm not sure. In any case. I'm closing this unless someone can reproduce it with the latest version. #759 is still valid.

jbccollins avatar Mar 06 '17 19:03 jbccollins

Good day everyone! - I'm having this issue wrt to version "react-datepicker": "^0.53.0"

My code:

<DatePicker
                    id="automation_datepicker_id"
                    inline
                    selected={state.date}
                    onChange={(event) => {
                        var date = event.format('DD/MM/YYYY')
                        this.props.inputChanged(date)
                        this.props.inputSubmit()
                    }}
                    minDate={moment().subtract(100, "years")}
                    maxDate={moment().add(1, "years")}
                    dateFormatCalendar={'MMMM'}
                    showYearDropdown
                    scrollableYearDropdown
                    yearDropdownItemNumber={50}
                    locale={locale.locale}
                    calendarClassName="rootCalendar"
                />

I'd really appreciate any assistance I can receive regarding this. The expected behaviour: The user can't see years beyond 2018 and before 100 years ago The behaviour: The yearDropdownItemNumber sets the years selectable in the drop down from 50 years in the past to 50 years in the future. I'd rather have a scrollable set than make the user hit the arrows in the scroll to go to previous years.

I really enjoyed having this datepicker available and appreciate all the hard work you guys have done! With kind regards!

meganhumphreys avatar Nov 16 '17 09:11 meganhumphreys

personally, i didn't want to show the last 18 years in the dropdown, so i used css:

 .react-datepicker__year-select option:nth-last-child(-n+18)  {
    display: none !important;
} 

MariusCimpoeru avatar Feb 02 '21 09:02 MariusCimpoeru