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 menu jitter when adding database select options https://github.com/siyuan-note/siyuan/issues/19627
Danielbeebc0a7fe00
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex 2c570b2f27..704d8ea657 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -88,6 +88,19 @@ export const duplicateCol = (options: {options.blockElement.setAttribute("updated", newUpdated);};+const getColOptionHTML = (item: IAVColumn["options"][number]) => {+ const ariaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc)}</div>` : "";+ return `<button class="b3-menu__item" data-option-row="true" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" data-color="${escapeAttr(item.color)}">+ <span draggable="true" class="b3-menu__icon b3-menu__icon--custom fn__grab"><svg><use xlink:href="#iconDrag"></use></svg></span>+ <div class="fn__flex-1 ariaLabel" data-position="parentW" aria-label="${ariaLabel}">+ <span class="b3-chip" style="${getAVColorStyle(item)}">+ <span class="fn__ellipsis">${escapeHtml(item.name)}</span>+ </span>+ </div>+ <svg class="b3-menu__action" data-type="setColOption"><use xlink:href="#iconEdit"></use></svg>+</button>`;+};+export const getEditHTML = (options: {protyle: IProtyle,colId: string,@@ -141,16 +154,7 @@ export const getEditHTML = (options: {colData.options = [];}colData.options.forEach(item => {- const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : "";- html += `<button class="b3-menu__item${html ? "" : " b3-menu__item--current"}" data-option-row="true" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" data-color="${escapeAttr(item.color)}">- <span draggable="true" class="b3-menu__icon b3-menu__icon--custom fn__grab"><svg><use xlink:href="#iconDrag"></use></svg></span>- <div class="fn__flex-1 ariaLabel" data-position="parentW" aria-label="${airaLabel}">- <span class="b3-chip" style="${getAVColorStyle(item)}">- <span class="fn__ellipsis">${escapeHtml(item.name)}</span>- </span>- </div>- <svg class="b3-menu__action" data-type="setColOption"><use xlink:href="#iconEdit"></use></svg>-</button>`;+ html += getColOptionHTML(item);});} else if (colData.type === "number") {html += `<button class="b3-menu__separator" data-id="separator_2"></button>@@ -501,6 +505,7 @@ export const bindEditEvent = (options: {options.menuElement.parentElement.remove();}if (event.key === "Enter") {+ event.preventDefault();let hasSelected = false;colData.options.find((item) => {if (addOptionElement.value === item.name) {@@ -526,20 +531,12 @@ export const bindEditEvent = (options: {avID,data: addOptionElement.value}]);- options.menuElement.innerHTML = getEditHTML({- protyle: options.protyle,- colId,- data: options.data,- isCustomAttr: options.isCustomAttr- });- bindEditEvent({- protyle: options.protyle,- menuElement: options.menuElement,- data: options.data,- isCustomAttr: options.isCustomAttr,- blockID: options.blockID- });- (options.menuElement.querySelector('[data-type="addOption"]') as HTMLInputElement).focus();+ // 保留输入框及其焦点,避免移动端软键盘因菜单重建而收起和弹出。+ const optionElements = options.menuElement.querySelectorAll('[data-option-row="true"]');+ const lastOptionElement = optionElements.length > 0 ?+ optionElements[optionElements.length - 1] : addOptionElement.parentElement;+ lastOptionElement.insertAdjacentHTML("afterend", getColOptionHTML(colData.options[colData.options.length - 1]));+ addOptionElement.value = "";// 添加选项后面板增高,需按首次锚点重新定位(sticky 锁底部,顶部上移避免溢出视口)const prevTop = parseFloat(options.menuElement.dataset.positionTop);if (!isNaN(prevTop)) {diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.tsindex 2a9db3cb96..566392e962 100644--- a/app/src/protyle/render/av/select.ts+++ b/app/src/protyle/render/av/select.ts@@ -288,7 +288,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,<div class="fn__hr"></div><textarea rows="1" placeholder="${window.siyuan.languages.addDesc}" class="b3-text-field fn__block" type="text" data-value="${escapeAttr(desc)}">${escapeHtml(desc)}</textarea></div>-<div class="fn__hr--small"></div>`,+${isMobile() ? "" : '<div class="fn__hr--small"></div>'}`,bind(element) {const inputElement = element.querySelector("input");element.classList.add("b3-menu__custom");@@ -322,6 +322,9 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,});}});+ if (isMobile()) {+ menu.addSeparator();+ }menu.addItem({id: "delete",label: window.siyuan.languages.delete,