Browse Source

:art: fix https://github.com/siyuan-note/siyuan/issues/9793

Vanessa 1 year ago
parent
commit
44d3db32e6

+ 12 - 0
app/src/boot/globalEvent/click.ts

@@ -21,6 +21,18 @@ export const globalClick = (event: MouseEvent & { target: HTMLElement }) => {
     if (!hasClosestByClassName(event.target, "pdf__outer")) {
     if (!hasClosestByClassName(event.target, "pdf__outer")) {
         hideAllElements(["pdfutil"]);
         hideAllElements(["pdfutil"]);
     }
     }
+    // dock float 时,点击空白处,隐藏 dock。场景:文档树上重命名后
+    if (!isWindow() && window.siyuan.layout.leftDock &&
+        !hasClosestByClassName(event.target, "b3-dialog--open", true) &&
+        !hasClosestByClassName(event.target, "b3-menu") &&
+        !hasClosestByClassName(event.target, "block__popover") &&
+        !hasClosestByClassName(event.target, "dock") &&
+        !hasClosestByClassName(event.target, "layout--float", true)
+    ) {
+        window.siyuan.layout.bottomDock.hideDock();
+        window.siyuan.layout.leftDock.hideDock();
+        window.siyuan.layout.rightDock.hideDock();
+    }
 
 
     const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
     const copyElement = hasTopClosestByClassName(event.target, "protyle-action__copy");
     if (copyElement) {
     if (copyElement) {

+ 1 - 4
app/src/boot/globalEvent/mousemove.ts

@@ -47,10 +47,7 @@ export const windowMouseMove = (event: MouseEvent & { target: HTMLElement }, mou
     if (!mouseIsEnter &&
     if (!mouseIsEnter &&
         event.buttons === 0 &&  // 鼠标按键被按下时不触发
         event.buttons === 0 &&  // 鼠标按键被按下时不触发
         window.siyuan.layout.bottomDock &&
         window.siyuan.layout.bottomDock &&
-        !isWindow() &&
-        !hasClosestByClassName(event.target, "b3-dialog", true) &&
-        !hasClosestByClassName(event.target, "block__popover", true) &&
-        !hasClosestByClassName(event.target, "b3-menu")) {
+        !isWindow()) {
         if (event.clientX < 43) {
         if (event.clientX < 43) {
             if (!window.siyuan.layout.leftDock.pin && window.siyuan.layout.leftDock.layout.element.clientWidth > 0 &&
             if (!window.siyuan.layout.leftDock.pin && window.siyuan.layout.leftDock.layout.element.clientWidth > 0 &&
                 // 隐藏停靠栏会导致点击两侧内容触发浮动面板弹出,因此需减小鼠标范围
                 // 隐藏停靠栏会导致点击两侧内容触发浮动面板弹出,因此需减小鼠标范围

+ 21 - 0
app/src/layout/dock/index.ts

@@ -256,6 +256,18 @@ export class Dock {
             this.layout.element.clientHeight === 0 && this.layout.element.style.height.startsWith("0")) {
             this.layout.element.clientHeight === 0 && this.layout.element.style.height.startsWith("0")) {
             return;
             return;
         }
         }
+        if ((
+            document.querySelector(".b3-dialog") ||
+            document.querySelector(".block__popover") ||
+            document.querySelector("#commonMenu:not(.fn__none)")
+        ) && (
+            window.siyuan.layout.leftDock?.layout.element.style.opacity === "1" ||
+            window.siyuan.layout.rightDock?.layout.element.style.opacity === "1" ||
+            window.siyuan.layout.bottomDock?.layout.element.style.opacity === "1"
+        )) {
+            return;
+        }
+
         if (!reset) {
         if (!reset) {
             this.layout.element.style.opacity = "1";
             this.layout.element.style.opacity = "1";
         }
         }
@@ -280,6 +292,15 @@ export class Dock {
         if (document.activeElement && this.layout.element.contains(document.activeElement) && document.activeElement.classList.contains("b3-text-field")) {
         if (document.activeElement && this.layout.element.contains(document.activeElement) && document.activeElement.classList.contains("b3-text-field")) {
             return;
             return;
         }
         }
+        const dialogElement = document.querySelector(".b3-dialog") as HTMLElement
+        const blockElement = document.querySelector(".block__popover") as HTMLElement
+        const menuElement = document.querySelector("#commonMenu:not(.fn__none)") as HTMLElement
+        if ((dialogElement && dialogElement.style.zIndex > this.layout.element.style.zIndex) ||  // 文档树上修改 emoji 时
+            (blockElement && blockElement.style.zIndex > this.layout.element.style.zIndex) ||  // 文档树上弹出悬浮层
+            (menuElement && menuElement.style.zIndex > this.layout.element.style.zIndex)  // 面板上弹出菜单时
+        ) {
+            return;
+        }
         if (this.position === "Left") {
         if (this.position === "Left") {
             this.layout.element.style.transform = `translateX(-${this.layout.element.clientWidth + 8}px)`;
             this.layout.element.style.transform = `translateX(-${this.layout.element.clientWidth + 8}px)`;
             this.layout.element.style.left = "";
             this.layout.element.style.left = "";