search

Home  >  Q&A  >  body text

The year drop-down option is not displayed

In react-datepicker, the year dropdown is not shown, all attributes are passed. But the year dropdown is still missing.

<DatePicker
  name={props.inputName}
  id={props.dateBoxId}
  placeholderText={props.placeholderText}
  autoComplete="off"
  dateFormat={props.dateFormat}
  selected={props.value}
  onChange={(e) => props.changeSelection(e, props.inputName)}
  timeInputLabel="Time:"
  disabled={props.disabled !== undefined ? props.disabled : false}
  showTimeInput={props.showTimeInput}
  minDate={subDays(new Date(), props.minDate)}
  maxDate={addDays(new Date(), props.maxDate)}
  onKeyDown={(e) => {
    e.preventDefault();
  }}
  showMonthDropdown
  showYearDropdown
  yearDropdownItemNumber={15}
  scrollableYearDropdown
/>;

P粉060528326P粉060528326289 days ago366

reply all(1)I'll reply

  • P粉208469050

    P粉2084690502024-03-30 13:00:30

    Try increasing the yearDropdownItemNumber value to 50. The possible reason is that it selects the minimum and maximum dates of the current year, and in the year dropdown, it shows 1997, while your current yearDropdownItemNumber value is only 15.

    reply
    0
  • Cancelreply