From 7981945bd36a438e604a5f31f48caea9ad8ae305 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 3 Apr 2024 10:43:34 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/10821 --- app/src/block/popover.ts | 4 ++-- app/src/menus/Menu.ts | 2 ++ app/src/menus/protyle.ts | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts index 55ee97335..92e1272a8 100644 --- a/app/src/block/popover.ts +++ b/app/src/block/popover.ts @@ -177,7 +177,7 @@ const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => { if (!popoverTargetElement && linkElement && linkElement.getAttribute("data-href")?.startsWith("siyuan://blocks")) { popoverTargetElement = linkElement; } - if (!popoverTargetElement) { + if (!popoverTargetElement || window.siyuan.menus.menu?.data.isSameNode(popoverTargetElement)) { // 移动到弹窗的 loading 元素上,但经过 settimeout 后 loading 已经被移除了 // https://ld246.com/article/1673596577519/comment/1673767749885#comments let targetElement = target; @@ -269,7 +269,7 @@ const getTarget = (event: MouseEvent & { target: HTMLElement }, aElement: false }; export const showPopover = async (app: App, showRef = false) => { - if (!popoverTargetElement) { + if (!popoverTargetElement || window.siyuan.menus.menu.data?.isSameNode(popoverTargetElement)) { return; } let ids: string[]; diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index bf434f5b0..461c92f4e 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -6,6 +6,7 @@ import {Constants} from "../constants"; export class Menu { public element: HTMLElement; + public data: any; // 用于记录当前菜单的数据 public removeCB: () => void; private wheelEvent: string; @@ -111,6 +112,7 @@ export class Menu { this.element.removeAttribute("style"); // zIndex window.siyuan.menus.menu.element.removeAttribute("data-name"); // 标识再次点击不消失 window.siyuan.menus.menu.element.removeAttribute("data-from"); // 标识是否在浮窗内打开 + window.siyuan.menus.menu.data = undefined; // 移除数据 } public append(element?: HTMLElement, index?: number) { diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 5e39c93ce..43c9e3872 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -604,6 +604,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { h: 26 }); const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true); + window.siyuan.menus.menu.data = element; window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app"); if (!protyle.disabled) { window.siyuan.menus.menu.element.querySelector("input").select();