Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Refine mobile bottom bar feedback and global menu navigation https://github.com/siyuan-note/siyuan/issues/18912

Daniel329f103dff65
diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scss
index 077653530e..958a3e3cc6 100644
--- a/app/src/assets/scss/main/_mobile.scss
+++ b/app/src/assets/scss/main/_mobile.scss
@@ -320,23 +320,9 @@ body.mobile-keyboard--open {
border-radius: var(--b3-border-radius);
color: var(--b3-theme-on-surface-light);
background: transparent;
-
- &::before {
- position: absolute;
- top: 50%;
- left: 50%;
- width: 40px;
- height: 40px;
- border-radius: 50%;
- background-color: transparent;
- content: "";
- pointer-events: none;
- transform: translate(-50%, -50%);
- }
+ -webkit-tap-highlight-color: transparent;
> svg {
- position: relative;
- z-index: 1;
width: 24px;
height: 24px;
flex-shrink: 0;
@@ -345,10 +331,6 @@ body.mobile-keyboard--open {
&:active,
&:focus-visible {
color: var(--b3-theme-on-surface);
-
- &::before {
- background-color: var(--b3-list-hover);
- }
}
&[disabled] {
@@ -359,8 +341,6 @@ body.mobile-keyboard--open {
.toolbar__tabs-count {
box-sizing: border-box;
- position: relative;
- z-index: 1;
display: flex;
align-items: center;
justify-content: center;
diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts
index 082c72ea54..85a989683f 100644
--- a/app/src/mobile/util/touch.ts
+++ b/app/src/mobile/util/touch.ts
@@ -26,6 +26,7 @@ import {
getSidebarOpeningOffset,
type MobileSidebarSide,
type MobileSwipeDirection,
+ shouldCloseGlobalMenu,
shouldDragOpenSidebar,
} from "./touchPanelGesture";
@@ -273,7 +274,11 @@ export const handleTouchEnd = (event: TouchEvent) => {
return;
}
- if (hasClosestByAttribute(target, "id", "menu", true)) {
+ const menuElement = hasClosestByAttribute(target, "id", "menu", true);
+ if (menuElement) {
+ if (!scrollBlock && isXScroll && shouldCloseGlobalMenu(firstDirection, reversing)) {
+ closePanel();
+ }
return;
}
@@ -472,7 +477,8 @@ export const handleTouchMove = (event: TouchEvent) => {
firstDirection = xDiff > 0 ? "toLeft" : "toRight";
if (firstXY === "x") {
const targetSidebar = getTargetSidebar(target);
- if (hasClosestByAttribute(target, "id", "menu", true) ||
+ const menuElement = hasClosestByAttribute(target, "id", "menu", true);
+ if ((menuElement && !shouldCloseGlobalMenu(firstDirection, false)) ||
(targetSidebar && !shouldDragOpenSidebar(targetSidebar, firstDirection))) {
firstXY = "y";
yDiff = undefined;
diff --git a/app/src/mobile/util/touchPanelGesture.test.ts b/app/src/mobile/util/touchPanelGesture.test.ts
index 8cb2bc6437..f7e35ead8c 100644
--- a/app/src/mobile/util/touchPanelGesture.test.ts
+++ b/app/src/mobile/util/touchPanelGesture.test.ts
@@ -6,6 +6,7 @@ import {
getSidebarClosingDirection,
getSidebarClosingOffset,
getSidebarOpeningOffset,
+ shouldCloseGlobalMenu,
shouldDragOpenSidebar,
} from "./touchPanelGesture";
@@ -31,6 +32,12 @@ describe("mobile sidebar touch gesture", () => {
assert.equal(getOpenSidebarReleaseAction("right", "toRight", true), "open");
});
+ it("closes the global menu only for an unreversed swipe to the right", () => {
+ assert.equal(shouldCloseGlobalMenu("toRight", false), true);
+ assert.equal(shouldCloseGlobalMenu("toRight", true), false);
+ assert.equal(shouldCloseGlobalMenu("toLeft", false), false);
+ });
+
it("mirrors and clamps closing transforms", () => {
assert.equal(getSidebarClosingOffset("left", 120, 300), -120);
assert.equal(getSidebarClosingOffset("left", -120, 300), 0);
diff --git a/app/src/mobile/util/touchPanelGesture.ts b/app/src/mobile/util/touchPanelGesture.ts
index 03c34c11b8..25df9f4b9d 100644
--- a/app/src/mobile/util/touchPanelGesture.ts
+++ b/app/src/mobile/util/touchPanelGesture.ts
@@ -14,6 +14,10 @@ export const shouldDragOpenSidebar = (side: MobileSidebarSide, direction: Mobile
return direction === getSidebarClosingDirection(side);
};
+export const shouldCloseGlobalMenu = (direction: MobileSwipeDirection, reversing: boolean) => {
+ return direction === "toRight" && !reversing;
+};
+
export const getOpenSidebarReleaseAction = (
side: MobileSidebarSide,
firstDirection: MobileSwipeDirection,