Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Datepicker|MonthPicker] Flippet visning av år. #2882

Merged
merged 4 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thick-poems-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---

Datepicker, MonthPicker: Valg av år i Select er reversert slik at øverste år er først. Dette er endret for å være bedre tilpassett ekspertsystemer der de mest relevante årene ble vist lengst unna museperker ved klikk.
KenAJoh marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const DropdownCaption = ({ displayMonth, id }: CaptionProps) => {
const handleMonthChange: React.ChangeEventHandler<HTMLSelectElement> = (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 });
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/date/monthpicker/MonthCaption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Loading