Skip to content

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

:bug: Unable to add new fields after grouping the database https://github.com/siyuan-note/siyuan/issues/18004

Daniel73f002b7653c
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 6630f54324..de9536a339 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -632,6 +632,11 @@ const addAttrViewColAnimation = (options: {
} else {
previousElement = item.querySelector(".av__cell").previousElementSibling;
}
+ // 分组视图下空分组或被虚拟滚动裁剪的行内可能找不到锚点单元格,此时跳过该行,
+ // 避免在 null 上调用 insertAdjacentHTML 抛出异常而中断整轮遍历 https://github.com/siyuan-note/siyuan/issues/18014
+ if (!previousElement) {
+ return;
+ }
let html = "";
if (item.classList.contains("av__row--header")) {
html = `<div class="av__cell av__cell--header" draggable="true" data-icon="${options.icon || ""}" data-col-id="${options.id}" data-dtype="${options.type}" data-wrap="false" style="width: 200px;">
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index b8c6384e36..68651d6944 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -845,5 +845,5 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
item.removeAttribute("data-loading");
});
});
- }, ["insertAttrViewBlock"].includes(operation.action) ? 2 : 100);
+ }, ["insertAttrViewBlock", "addAttrViewCol", "removeAttrViewCol", "duplicateAttrViewKey"].includes(operation.action) ? 2 : 100);
};