An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prevent mobile block menu flicker when restoring the keyboard https://github.com/siyuan-note/siyuan/issues/19492
Daniel9c07fc119239
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.tsindex 618df8b0ad..cbe32f3412 100644--- a/app/src/menus/Menu.ts+++ b/app/src/menus/Menu.ts@@ -310,16 +310,20 @@ export class Menu {window.setTimeout(() => this.remove(), Constants.TIMEOUT_DBLCLICK);return;}+ const restoreKeyboard = this.restoreKeyboard;+ if (restoreKeyboard) {+ // 先隐藏菜单,避免软键盘改变视口时将退出中的菜单重新顶入可视区域。+ this.removeImmediately();+ // 在关闭手势中恢复焦点,使浏览器端也能响应用户操作弹出软键盘。+ restoreKeyboard();+ return;+ }clearTimeout(fullscreenCloseTimeout);this.element.style.transition = "";void this.element.offsetHeight;this.element.style.transform = "translateY(100%)";this.hideFullscreenScrim();fullscreenCloseTimeout = window.setTimeout(() => this.removeImmediately(), Constants.TIMEOUT_DBLCLICK);- const restoreKeyboard = this.restoreKeyboard;- this.restoreKeyboard = undefined;- // 在关闭手势中恢复焦点,使浏览器端也能响应用户操作弹出软键盘。- restoreKeyboard?.();}private updateSheetTitle() {diff --git a/app/src/menus/menuKeyboardRestore.test.ts b/app/src/menus/menuKeyboardRestore.test.tsindex 33adfd4d91..1b06768510 100644--- a/app/src/menus/menuKeyboardRestore.test.ts+++ b/app/src/menus/menuKeyboardRestore.test.ts@@ -122,6 +122,29 @@ describe("mobile menu keyboard lifecycle", () => {assert.equal(events.filter(event => event === "restore").length, 1);});+ it("hides the sheet before restoring the keyboard can resize the viewport", () => {+ const {menu, element, tick} = setup();+ menu.fullscreen("all", () => {+ assert.equal(element.classList.contains("fn__none"), true);+ assert.equal(element.classList.contains("b3-menu--sheet"), false);+ });+ tick(500, 808);+ tick(532);+ menu.closeSheet();+ tick(550, 476);+ assert.equal(element.classList.contains("fn__none"), true);+ });++ it("keeps the closing animation when no keyboard needs restoring", () => {+ const {menu, element, finishClose} = setup();+ menu.fullscreen();+ menu.closeSheet();+ assert.equal(element.style.transform, "translateY(100%)");+ assert.equal(element.classList.contains("fn__none"), false);+ finishClose();+ assert.equal(element.classList.contains("fn__none"), true);+ });+it("restores on system back but leaves submenu back navigation alone", () => {const {menu, events, element} = setup();menu.fullscreen("all", () => events.push("restore"));@@ -144,13 +167,12 @@ describe("mobile menu keyboard lifecycle", () => {it("cancels the old closing timer when another menu opens", () => {const {menu, element, events, finishClose} = setup();- menu.fullscreen("all", () => events.push("restore-first"));+ menu.fullscreen();menu.closeSheet();menu.fullscreen("all", () => events.push("restore-second"));finishClose();assert.equal(element.classList.contains("fn__none"), false);menu.closeSheet();- assert.equal(events.filter(event => event === "restore-first").length, 1);assert.equal(events.filter(event => event === "restore-second").length, 1);});});