Skip to content

Commit

Permalink
🐛 MonthCaption disabled prev/next-knapper når de skulle være enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Jan 10, 2024
1 parent 2a99928 commit 3d02f95
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions @navikt/core/react/src/date/monthpicker/MonthCaption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ export const MonthCaption = () => {
toYear(setYear(year, newYear));
};

const hasPrevYear = () => {
const disablePreviousYear = () => {
return fromDate
? isBefore(year?.getFullYear() - 1, fromDate?.getFullYear())
: true;
: false;
};

const hasNextYear = () => {
const disableNextYear = () => {
return toDate
? isAfter(year?.getFullYear() + 1, toDate?.getFullYear())
: true;
: false;
};

return (
<div className="navds-date__caption">
<Button
className="navds-date__caption-button"
disabled={hasPrevYear()}
disabled={disablePreviousYear()}
onClick={() => handleButtonClick(-1)}
aria-label={labelPrevYear(locale?.code)}
icon={<ArrowLeftIcon aria-hidden />}
Expand Down Expand Up @@ -88,7 +88,7 @@ export const MonthCaption = () => {
)}
<Button
className="navds-date__caption-button"
disabled={hasNextYear()}
disabled={disableNextYear()}
onClick={() => handleButtonClick(1)}
aria-label={labelNextYear(locale?.code)}
icon={<ArrowRightIcon aria-hidden />}
Expand Down

0 comments on commit 3d02f95

Please sign in to comment.