Compare commits

...
Author SHA1 Message Date
Ken 2d2d57f6fc fix(monthpicker): isValidDate was inverted when setting validation 2026-09-29 11:58:15 +02:00
2 changed files with 9 additions and 2 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---
MonthPicker: `onValidate` from `useMonthpicker` now reports `isInvalid: true` for text that can't be parsed as a month, and `false` for a valid but disabled month.
@@ -273,13 +273,15 @@ export const useMonthpicker = (
const isBefore = getIsBefore({ fromDate, date: month });
const isAfter = getIsAfter({ toDate, date: month });
const isMonthValidDate = isValidDate(month);
if (
!isValidDate(month) ||
!isMonthValidDate ||
(disabled && dateMatchModifiers(month, disabled))
) {
updateMonth(undefined);
updateValidation({
isInvalid: isValidDate(month),
isInvalid: !isMonthValidDate,
isDisabled: disabled && dateMatchModifiers(month, disabled),
isValidMonth: false,
isEmpty: !e.target.value,