From fbcca2a7e3a11a0772e8c45c2a674855f56ed4f1 Mon Sep 17 00:00:00 2001 From: Emil Carlsson Date: Tue, 11 Jun 2024 12:04:54 +0200 Subject: [PATCH] fix: Add safe navigation to arrow position calculation Add safe navigation to arrow position calculation to prevent errors when any of the elements in the calculation does not exist. --- src/VueDatePicker/components/DatepickerMenu.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VueDatePicker/components/DatepickerMenu.vue b/src/VueDatePicker/components/DatepickerMenu.vue index 1e50d602..e7c0682c 100644 --- a/src/VueDatePicker/components/DatepickerMenu.vue +++ b/src/VueDatePicker/components/DatepickerMenu.vue @@ -249,8 +249,8 @@ if (defaultedConfig.value.arrowLeft) return defaultedConfig.value.arrowLeft; const menuRect = dpMenuRef.value?.getBoundingClientRect(); const inputRect = props.getInputRect(); - if (inputRect.width < calendarWidth.value && inputRect.left <= (menuRect?.left ?? 0)) { - return `${inputRect.width / 2}px`; + if (inputRect?.width < calendarWidth?.value && inputRect?.left <= (menuRect?.left ?? 0)) { + return `${inputRect?.width / 2}px`; } return '50%'; });