fix: global `mousedown` handler in picker input hooks (#5657)
parent
3cd7ca3e0b
commit
18ce00d239
|
@ -1,5 +1,5 @@
|
|||
import type { ComputedRef, HTMLAttributes, Ref } from 'vue';
|
||||
import { onBeforeUnmount, watchEffect, watch, ref, computed } from 'vue';
|
||||
import { onBeforeUnmount, onMounted, watch, ref, computed } from 'vue';
|
||||
import type { FocusEventHandler } from '../../_util/EventInterface';
|
||||
import KeyCode from '../../_util/KeyCode';
|
||||
import { addGlobalMousedownEvent, getTargetFromEvent } from '../utils/uiUtil';
|
||||
|
@ -148,14 +148,11 @@ export default function usePickerInput({
|
|||
});
|
||||
const globalMousedownEvent = ref();
|
||||
// Global click handler
|
||||
watchEffect(
|
||||
() =>
|
||||
globalMousedownEvent.value &&
|
||||
globalMousedownEvent.value()(
|
||||
(globalMousedownEvent.value = addGlobalMousedownEvent((e: MouseEvent) => {
|
||||
onMounted(() => {
|
||||
globalMousedownEvent.value = addGlobalMousedownEvent((e: MouseEvent) => {
|
||||
const target = getTargetFromEvent(e);
|
||||
|
||||
if (open) {
|
||||
if (open.value) {
|
||||
const clickedOutside = isClickOutside(target);
|
||||
|
||||
if (!clickedOutside) {
|
||||
|
@ -169,9 +166,8 @@ export default function usePickerInput({
|
|||
triggerOpen(false);
|
||||
}
|
||||
}
|
||||
})),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
globalMousedownEvent.value && globalMousedownEvent.value();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue