diff --git a/.changeset/thick-poems-design.md b/.changeset/thick-poems-design.md new file mode 100644 index 0000000000..bacbaca387 --- /dev/null +++ b/.changeset/thick-poems-design.md @@ -0,0 +1,5 @@ +--- +"@navikt/ds-react": patch +--- + +Datepicker, MonthPicker: Rekkefølgen på årstall i Select er reversert slik at siste år er øverst. Dette er endret for å være bedre tilpasset ekspertsystemer der de mest relevante årene ble vist lengst unna musepeker ved klikk. diff --git a/@navikt/core/react/src/date/datepicker/parts/DropdownCaption.tsx b/@navikt/core/react/src/date/datepicker/parts/DropdownCaption.tsx index df9548e7c0..8dc242046c 100644 --- a/@navikt/core/react/src/date/datepicker/parts/DropdownCaption.tsx +++ b/@navikt/core/react/src/date/datepicker/parts/DropdownCaption.tsx @@ -37,7 +37,11 @@ export const DropdownCaption = ({ displayMonth, id }: CaptionProps) => { const handleMonthChange: React.ChangeEventHandler = (e) => goToMonth(setMonth(startOfMonth(displayMonth), Number(e.target.value))); - const years = getYears(fromDate, toDate, displayMonth.getFullYear()); + const years = getYears( + fromDate, + toDate, + displayMonth.getFullYear(), + ).reverse(); const months = getMonths(fromDate, toDate, displayMonth); const previousLabel = labelPrevious(previousMonth, { locale }); diff --git a/@navikt/core/react/src/date/monthpicker/MonthCaption.tsx b/@navikt/core/react/src/date/monthpicker/MonthCaption.tsx index c048611c31..f0a72e9a0b 100644 --- a/@navikt/core/react/src/date/monthpicker/MonthCaption.tsx +++ b/@navikt/core/react/src/date/monthpicker/MonthCaption.tsx @@ -35,7 +35,7 @@ export const MonthCaption = () => { if (!years.map((x) => x.getFullYear()).includes(year.getFullYear())) { years.push(setYear(startOfYear(new Date()), year.getFullYear())); } - years.sort((a, b) => a.getFullYear() - b.getFullYear()); + years.sort((a, b) => b.getFullYear() - a.getFullYear()); } const handleYearChange = (e) =>