This commit is contained in:
tamaina 2023-08-04 14:53:47 +00:00
parent 5a3d7f9ef8
commit 58894838f0
1 changed files with 5 additions and 4 deletions

View File

@ -125,7 +125,7 @@ watch(() => props.items, () => {
immediate: true, immediate: true,
}); });
let childMenu = ref<MenuItem[] | null>(); const childMenu = ref<MenuItem[] | null>();
let childTarget = $shallowRef<HTMLElement | null>(); let childTarget = $shallowRef<HTMLElement | null>();
function closeChild() { function closeChild() {
@ -142,7 +142,7 @@ const onGlobalMousedown = (event: MouseEvent) => {
if (childTarget && (event.target === childTarget || childTarget.contains(event.target))) return; if (childTarget && (event.target === childTarget || childTarget.contains(event.target))) return;
if (child && child.checkHit(event)) return; if (child && child.checkHit(event)) return;
closeChild(); closeChild();
} };
let childCloseTimer: null | number = null; let childCloseTimer: null | number = null;
function onItemMouseEnter(item) { function onItemMouseEnter(item) {
@ -182,7 +182,8 @@ function showChildren(item: MenuParent, ev: MouseEvent) {
emit('hide'); emit('hide');
} else { } else {
childTarget = ev.currentTarget ?? ev.target; childTarget = ev.currentTarget ?? ev.target;
childMenu = children as Ref<MenuItem[]>; //
childMenu.value = children.value as MenuItem[];
childShowingItem = item; childShowingItem = item;
} }
} }
@ -212,7 +213,7 @@ function switchItem(item: MenuSwitch & { ref: any }) {
onMounted(() => { onMounted(() => {
if (props.viaKeyboard) { if (props.viaKeyboard) {
nextTick(() => { nextTick(() => {
focusNext(itemsEl.children[0], true, false); if (itemsEl) focusNext(itemsEl.children[0], true, false);
}); });
} }