Skip to content

Commit

Permalink
Changes calendar year selection to a dropdown selector instead of num…
Browse files Browse the repository at this point in the history
…ber input.
  • Loading branch information
eireland committed Apr 26, 2024
1 parent dbca317 commit 1b8ca24
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/components/date-range/calendar-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const CalendarHeader = ({calendarType, handleSelectCalendar}: ICalendarHe
handleSelectCalendar();
};

const handleYearChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const handleYearChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const newYear = Number(e.target.value);
handleSetDate(new Date(newYear, month, day));
handleSelectCalendar();
Expand All @@ -80,15 +80,15 @@ export const CalendarHeader = ({calendarType, handleSelectCalendar}: ICalendarHe
);
})}
</select>
<input
className={`year select`}
value={year}
type="number"
min={1850}
max={new Date().getFullYear()}
step={1}
onChange={handleYearChange}
/>
<select className={`year select`} value={year} onChange={handleYearChange}>
{Array.from({length: new Date().getFullYear() - 1850 + 1}, (_, i) => i + 1850).map((_year, ix) => {
return (
<option key={ix} value={_year}>
{_year}
</option>
);
})}
</select>
</div>
<div className={`arrow next`} onClick={handleNext}><ArrowForwardIosIcon/></div>
</div>
Expand Down

0 comments on commit 1b8ca24

Please sign in to comment.