Skip to content

Commit e861581

Browse files
committed
fix: Prevent range select on text-input if end date is before start date (fixes #837)
1 parent b6d1154 commit e861581

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/VueDatePicker/components/DatepickerInput.vue

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import type { PropType } from 'vue';
8585
import type { DynamicClass, InternalModuleValue } from '@/interfaces';
8686
import { checkStopPropagation } from '@/utils/util';
87+
import { isAfter } from 'date-fns';
8788
8889
defineOptions({
8990
compatConfig: {
@@ -174,6 +175,7 @@
174175
if (dateOne) {
175176
const parsedDateOne = parser(dateOne.trim());
176177
const parsedDateTwo = dateTwo ? parser(dateTwo.trim()) : null;
178+
if (isAfter(parsedDateOne as Date, parsedDateTwo as Date)) return;
177179
178180
const parsedArr = parsedDateOne && parsedDateTwo ? [parsedDateOne, parsedDateTwo] : [parsedDateOne];
179181
if (checkMinMaxRange(parsedDateTwo as Date, parsedArr as InternalModuleValue, 0)) {

0 commit comments

Comments
 (0)