Skip to content

Commit 1a53385

Browse files
committed
fix: month-picker unable to select month when allowed-dates prop is provided (fixes #1075)
1 parent f175a71 commit 1a53385

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/VueDatePicker/composables/validation.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
setTimeValue,
1313
} from '@/utils/date-utils';
1414
import { useDefaults } from '@/composables/defaults';
15-
import { convertType, getMapDate } from '@/utils/util';
15+
import { convertType, getMapDate, getMapKeyType } from '@/utils/util';
1616

1717
import type { InternalModuleValue, DisabledTimesFn, DisabledTime, TimeModel, MaybeDate } from '@/interfaces';
1818
import type { PickerBasePropsType, AllPropsType } from '@/props';
@@ -111,7 +111,7 @@ export const useValidation = (props: PickerBasePropsType | AllPropsType) => {
111111
const checkAllowedDates = (date: Date) => {
112112
if (Array.isArray(propDates.value.allowedDates) && !propDates.value.allowedDates.length) return true;
113113
if (propDates.value.allowedDates) {
114-
return !getMapDate(date, propDates.value.allowedDates);
114+
return !getMapDate(date, propDates.value.allowedDates, getMapKeyType(props.monthPicker, props.yearPicker));
115115
}
116116
return false;
117117
};

src/VueDatePicker/utils/util.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ function dayNameIntlMapper(locale: string) {
2828
return (day: number) => {
2929
const formattedDate = new Intl.DateTimeFormat(locale, {
3030
weekday: 'short',
31-
timeZone: 'UTC'
31+
timeZone: 'UTC',
3232
}).format(new Date(`2017-01-0${day}T00:00:00+00:00`));
3333

3434
// Arabic locale requires different slice indexes to get correct abbreviation
3535
return locale === 'ar' ? formattedDate.slice(2, 5) : formattedDate.slice(0, 2);
36-
}
37-
};
36+
};
37+
}
3838

3939
function dayNameDateFnsMapper(formatLocale: Locale) {
4040
return (day: number) => {

0 commit comments

Comments
 (0)