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 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 type { FocusEventHandler } from '../../_util/EventInterface';
|
||||||
import KeyCode from '../../_util/KeyCode';
|
import KeyCode from '../../_util/KeyCode';
|
||||||
import { addGlobalMousedownEvent, getTargetFromEvent } from '../utils/uiUtil';
|
import { addGlobalMousedownEvent, getTargetFromEvent } from '../utils/uiUtil';
|
||||||
|
@ -148,14 +148,11 @@ export default function usePickerInput({
|
||||||
});
|
});
|
||||||
const globalMousedownEvent = ref();
|
const globalMousedownEvent = ref();
|
||||||
// Global click handler
|
// Global click handler
|
||||||
watchEffect(
|
onMounted(() => {
|
||||||
() =>
|
globalMousedownEvent.value = addGlobalMousedownEvent((e: MouseEvent) => {
|
||||||
globalMousedownEvent.value &&
|
|
||||||
globalMousedownEvent.value()(
|
|
||||||
(globalMousedownEvent.value = addGlobalMousedownEvent((e: MouseEvent) => {
|
|
||||||
const target = getTargetFromEvent(e);
|
const target = getTargetFromEvent(e);
|
||||||
|
|
||||||
if (open) {
|
if (open.value) {
|
||||||
const clickedOutside = isClickOutside(target);
|
const clickedOutside = isClickOutside(target);
|
||||||
|
|
||||||
if (!clickedOutside) {
|
if (!clickedOutside) {
|
||||||
|
@ -169,9 +166,8 @@ export default function usePickerInput({
|
||||||
triggerOpen(false);
|
triggerOpen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})),
|
});
|
||||||
),
|
});
|
||||||
);
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
globalMousedownEvent.value && globalMousedownEvent.value();
|
globalMousedownEvent.value && globalMousedownEvent.value();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue