Skip to content

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

:bug: Preserve command panel input focus on Android https://github.com/siyuan-note/siyuan/issues/19209

Daniel5f59083fa112
diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.ts
index c73b533b2b..0e525414da 100644
--- a/app/src/mobile/menu/index.ts
+++ b/app/src/mobile/menu/index.ts
@@ -408,8 +408,11 @@ export const initRightMenu = (app: App) => {
}
}
};
- const resetSearch = () => {
- activeBlur();
+ const resetSearch = (preserveKeyboard = false) => {
+ // 转入输入型弹窗时保留键盘,避免 Android 异步隐藏键盘回调清除新输入框的焦点。
+ if (!preserveKeyboard) {
+ activeBlur();
+ }
selectedTabId = undefined;
searchMountQueue.invalidate();
searchElement.value = "";
@@ -424,8 +427,8 @@ export const initRightMenu = (app: App) => {
syncSearch();
}
});
- menuElement.addEventListener(MOBILE_MENU_CLOSE_EVENT, () => {
- resetSearch();
+ menuElement.addEventListener(MOBILE_MENU_CLOSE_EVENT, (event: CustomEvent<{preserveKeyboard?: boolean}>) => {
+ resetSearch(event.detail?.preserveKeyboard);
const callback = takeMobileMenuReturnCallback();
if (callback) {
window.setTimeout(callback);
@@ -520,7 +523,7 @@ export const initRightMenu = (app: App) => {
event.stopPropagation();
break;
} else if (target.id === "menuCommand") {
- closePanel();
+ closePanel({preserveKeyboard: true});
commandPanel(app);
event.preventDefault();
event.stopPropagation();
diff --git a/app/src/mobile/util/closePanel.ts b/app/src/mobile/util/closePanel.ts
index ef3398ec0b..4a46efb65e 100644
--- a/app/src/mobile/util/closePanel.ts
+++ b/app/src/mobile/util/closePanel.ts
@@ -14,11 +14,11 @@ export const showPanelMask = () => {
return maskElement;
};
-export const closePanel = () => {
+export const closePanel = (options: {preserveKeyboard?: boolean} = {}) => {
destroyModel();
const menuElement = document.getElementById("menu");
if (menuElement) {
- menuElement.dispatchEvent(new CustomEvent(MOBILE_MENU_CLOSE_EVENT));
+ menuElement.dispatchEvent(new CustomEvent(MOBILE_MENU_CLOSE_EVENT, {detail: options}));
menuElement.style.removeProperty("transform");
menuElement.style.removeProperty("z-index");
}
diff --git a/app/src/mobile/util/mobileBottomBar.ts b/app/src/mobile/util/mobileBottomBar.ts
index 3179ea9569..4e1399a09e 100644
--- a/app/src/mobile/util/mobileBottomBar.ts
+++ b/app/src/mobile/util/mobileBottomBar.ts
@@ -299,8 +299,7 @@ export const initMobileBottomBar = (app: App) => {
if (isMobileBlockSelecting()) {
return;
}
- activeBlur();
- closePanel();
+ closePanel({preserveKeyboard: true});
commandPanel(app);
});
};