From 933d9a89d929c87e2bd7a7462745a39db1ac9648 Mon Sep 17 00:00:00 2001 From: melloware Date: Fri, 26 Aug 2022 13:31:47 -0400 Subject: [PATCH] Fix #3192: Calendar monthpicker fix for disabled dates --- components/lib/calendar/Calendar.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 9000885bf6..fc05326231 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -4,8 +4,8 @@ import { Button } from '../button/Button'; import { useMountEffect, useOverlayListener, usePrevious, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks'; import { InputText } from '../inputtext/InputText'; import { OverlayService } from '../overlayservice/OverlayService'; -import { DomHandler, ObjectUtils, classNames, mask, ZIndexUtils, UniqueComponentId } from '../utils/Utils'; import { Ripple } from '../ripple/Ripple'; +import { classNames, DomHandler, mask, ObjectUtils, UniqueComponentId, ZIndexUtils } from '../utils/Utils'; import { CalendarPanel } from './CalendarPanel'; export const Calendar = React.memo( @@ -1681,7 +1681,7 @@ export const Calendar = React.memo( if (props.minDate.getMonth() > month) { validMin = false; } else if (props.minDate.getMonth() === month) { - if (props.minDate.getDate() > day) { + if (day > 0 && props.minDate.getDate() > day) { validMin = false; } } @@ -1695,7 +1695,7 @@ export const Calendar = React.memo( if (props.maxDate.getMonth() < month) { validMax = false; } else if (props.maxDate.getMonth() === month) { - if (props.maxDate.getDate() < day) { + if (day > 0 && props.maxDate.getDate() < day) { validMax = false; } } @@ -3031,7 +3031,7 @@ export const Calendar = React.memo(
{monthPickerValues().map((m, i) => { return ( - onMonthSelect(event, i)} key={`month${i + 1}`} className={classNames('p-monthpicker-month', { 'p-highlight': isMonthSelected(i), 'p-disabled': !isSelectable(1, i, currentYear) })}> + onMonthSelect(event, i)} key={`month${i + 1}`} className={classNames('p-monthpicker-month', { 'p-highlight': isMonthSelected(i), 'p-disabled': !isSelectable(0, i, currentYear) })}> {m} );