Skip to content

Commit 46052b3

Browse files
committed
fix: Add touch end for all touch devices
1 parent c74a973 commit 46052b3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/VueDatePicker/components/DatePicker/DpCalendar.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
checkStopPropagation,
123123
getDayNames,
124124
getDefaultMarker,
125-
isIOS,
125+
isTouchDevice,
126126
unrefElement,
127127
} from '@/utils/util';
128128
import { useArrowNavigation, useDefaults } from '@/composables';
@@ -382,7 +382,7 @@
382382
};
383383
384384
const onDateSelect = (ev: Event, dayVal: ICalendarDay, isClick = true) => {
385-
if (!isClick && isIOS()) return;
385+
if (!isClick && isTouchDevice()) return;
386386
if (!defaultedMultiDates.value.enabled || defaultedConfig.value.allowPreventDefault) {
387387
checkStopPropagation(ev, defaultedConfig.value);
388388
emit('select-date', dayVal);

src/VueDatePicker/utils/util.ts

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ export const isIOS = () => {
319319
);
320320
};
321321

322+
export const isTouchDevice = () => {
323+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
324+
};
325+
322326
export const getMapKeyType = (monthPicker: boolean, yearPicker: boolean): MAP_KEY_FORMAT => {
323327
if (monthPicker) return MAP_KEY_FORMAT.MONTH_AND_YEAR;
324328
if (yearPicker) return MAP_KEY_FORMAT.YEAR;

0 commit comments

Comments
 (0)