|
120 | 120 | </template>
|
121 | 121 |
|
122 | 122 | <script lang="ts" setup>
|
123 |
| - import { computed, onMounted, onUnmounted, ref, toValue, useSlots } from 'vue'; |
| 123 | + import { computed, onUnmounted, onMounted, ref, toValue, useSlots } from 'vue'; |
124 | 124 |
|
125 | 125 | import ActionRow from '@/components/ActionRow.vue';
|
126 | 126 |
|
|
205 | 205 | const dynCmpRef = ref<any>(null);
|
206 | 206 | const isMenuActive = ref(false);
|
207 | 207 |
|
| 208 | + const stopDefault = (event: Event) => { |
| 209 | + isMenuActive.value = true; |
| 210 | + if (defaultedConfig.value.allowPreventDefault) { |
| 211 | + event.preventDefault(); |
| 212 | + } |
| 213 | + checkStopPropagation(event, defaultedConfig.value, true); |
| 214 | + }; |
| 215 | +
|
208 | 216 | onMounted(() => {
|
209 | 217 | if (!props.shadow) {
|
210 | 218 | menuMount.value = true;
|
211 | 219 | getCalendarWidth();
|
212 | 220 | window.addEventListener('resize', getCalendarWidth);
|
213 | 221 |
|
214 |
| - const menu = unrefElement(dpMenuRef); |
215 |
| - if (menu && !defaultedTextInput.value.enabled && !defaultedInline.value.enabled) { |
| 222 | + if (dpMenuRef.value && !defaultedTextInput.value.enabled && !defaultedInline.value.enabled) { |
216 | 223 | setMenuFocused(true);
|
217 | 224 | focusMenu();
|
218 | 225 | }
|
219 |
| - if (menu) { |
220 |
| - const stopDefault = (event: Event) => { |
221 |
| - isMenuActive.value = true; |
222 |
| - if (defaultedConfig.value.allowPreventDefault) { |
223 |
| - event.preventDefault(); |
224 |
| - } |
225 |
| - checkStopPropagation(event, defaultedConfig.value, true); |
226 |
| - }; |
227 |
| - menu.addEventListener('pointerdown', stopDefault); |
228 |
| - menu.addEventListener('mousedown', stopDefault); |
| 226 | + if (dpMenuRef.value) { |
| 227 | + dpMenuRef.value.addEventListener('pointerdown', stopDefault); |
| 228 | + dpMenuRef.value.addEventListener('mousedown', stopDefault); |
229 | 229 | }
|
230 | 230 | }
|
231 | 231 | document.addEventListener('mousedown', handleClickOutside);
|
232 | 232 | });
|
233 | 233 |
|
234 | 234 | onUnmounted(() => {
|
235 | 235 | window.removeEventListener('resize', getCalendarWidth);
|
236 |
| - document.addEventListener('mousedown', handleClickOutside); |
| 236 | + document.removeEventListener('mousedown', handleClickOutside); |
| 237 | + dpMenuRef.value?.removeEventListener('pointerdown', stopDefault); |
| 238 | + dpMenuRef.value?.removeEventListener('mousedown', stopDefault); |
237 | 239 | });
|
238 | 240 |
|
239 | 241 | const getCalendarWidth = (): void => {
|
|
0 commit comments