diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index a55b0b961..f4428fa3d 100644 --- a/app/src/protyle/render/av/render.ts +++ b/app/src/protyle/render/av/render.ts @@ -58,13 +58,16 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v fetchPost("/api/av/setDatabaseBlockView", {id: e.dataset.nodeId, viewID}); e.setAttribute(Constants.CUSTOM_SY_AV_VIEW, newViewID); } + let searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement; + const isSearching = searchInputElement && document.activeElement.isSameNode(searchInputElement); + const query = searchInputElement?.value || ""; fetchPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), { id: e.getAttribute("data-av-id"), created, snapshot, pageSize: parseInt(e.dataset.pageSize) || undefined, viewID: newViewID, - query: (e.querySelector('.b3-text-field[data-type="av-search"]') as HTMLInputElement)?.value || "" + query }, (response) => { const data = response.data.view as IAVTable; if (!e.dataset.pageSize) { @@ -175,7 +178,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}`; e.firstElementChild.outerHTML = `
-
+
${tabHTML}
@@ -203,7 +206,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}
`;
- +
@@ -271,7 +274,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}
`; const avMaskElement = document.querySelector(".av__mask"); if (avMaskElement) { (avMaskElement.querySelector("textarea, input") as HTMLTextAreaElement)?.focus(); - } else if (!document.querySelector(".av__panel")) { + } else if (!document.querySelector(".av__panel") && !isSearching) { focusBlock(e); } } @@ -280,7 +283,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}
`; const range = getSelection().getRangeAt(0); if (!hasClosestByClassName(range.startContainer, "av__title")) { const blockElement = hasClosestBlock(range.startContainer); - if (blockElement && e.isSameNode(blockElement)) { + if (blockElement && e.isSameNode(blockElement) && !isSearching) { focusBlock(e); } } @@ -290,7 +293,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}
`; cb(); } const viewsElement = e.querySelector(".av__views") as HTMLElement; - const searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement; + searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement; + searchInputElement.value = query; + if (isSearching) { + searchInputElement.focus(); + } searchInputElement.addEventListener("input", (event: KeyboardEvent) => { if (event.isComposing) { return;