Skip to content

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

:bug: Prevent mobile database menus from restoring keyboard focus https://github.com/siyuan-note/siyuan/issues/18845

Daniel13c35aef189a
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index 87e574a4aa..fe33f926b0 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -993,9 +993,9 @@ export const hideKeyboardToolbarByApp = (preserveSelection = false) => {
return result;
};
-export const activeBlur = () => {
+export const activeBlur = (force = false) => {
const now = Date.now();
- if (now < keyboardLockUntil) {
+ if (!force && now < keyboardLockUntil) {
console.warn(`activeBlur blocked by lock (remaining: ${keyboardLockUntil - now}ms)`);
return;
}
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 595c3beba4..b366d66bbe 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -650,7 +650,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
return true;
} else if (target.classList.contains("item") && target.parentElement.classList.contains("layout-tab-bar")) {
/// #if MOBILE
- activeBlur();
+ activeBlur(true);
/// #endif
if (target.classList.contains("item--focus")) {
openViewMenu({protyle, blockElement, element: target});
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index ee55f54ded..b2a4bb2f5c 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -480,7 +480,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
html = `<input type="number" spellcheck="false" value="${cellElements[0].firstElementChild.getAttribute("data-content")}" ${style} class="b3-text-field">`;
} else {
/// #if MOBILE
- activeBlur();
+ activeBlur(true);
/// #endif
if (["select", "mSelect"].includes(type)) {
if (blockElement.getAttribute("data-rendering") === "true") {
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 80fe398f1b..2edbb05fdf 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -904,6 +904,9 @@ export const showAVColumnWidthMenu = (protyle: IProtyle, blockElement: HTMLEleme
};
export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElement: HTMLElement) => {
+ /// #if MOBILE
+ activeBlur(true);
+ /// #endif
const type = cellElement.getAttribute("data-dtype") as TAVCol;
const colId = cellElement.getAttribute("data-col-id");
const avID = blockElement.getAttribute("data-av-id");
@@ -1434,11 +1437,13 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
y: cellRect.bottom,
h: cellRect.height
});
+ /// #if !MOBILE
const inputElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement;
if (inputElement) {
inputElement.select();
inputElement.focus();
}
+ /// #endif
};
const removeColByMenu = (options: {
@@ -1549,7 +1554,7 @@ const genUpdateColItem = (type: TAVCol, oldType: TAVCol) => {
export const addCol = (protyle: IProtyle, blockElement: Element, previousID?: string) => {
/// #if MOBILE
- activeBlur();
+ activeBlur(true);
/// #endif
const menu = new Menu(Constants.MENU_AV_HEADER_ADD);
const avID = blockElement.getAttribute("data-av-id");