From 81ae9a22cd05cd7687ab097b4fabe9d25176b4c8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 2 Aug 2023 20:19:04 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/insider/issues/1114 --- app/src/protyle/render/av/col.ts | 5 ++++- app/src/protyle/render/av/select.ts | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 1a2bf077e..24e7945c4 100644 --- a/app/src/protyle/render/av/col.ts +++ b/app/src/protyle/render/av/col.ts @@ -135,7 +135,7 @@ ${html} export const bindEditEvent = (options: { protyle: IProtyle, data: IAV, menuElement: HTMLElement }) => { const avID = options.data.id; - const colId = options.menuElement.firstElementChild.getAttribute("data-col-id"); + const colId = options.menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"); const colData = options.data.view.columns.find((item: IAVColumn) => item.id === colId); const nameElement = options.menuElement.querySelector('[data-type="name"]') as HTMLInputElement; nameElement.addEventListener("blur", () => { @@ -164,6 +164,9 @@ export const bindEditEvent = (options: { protyle: IProtyle, data: IAV, menuEleme } if (event.key === "Escape") { options.menuElement.parentElement.remove(); + } else if (event.key === "Enter") { + nameElement.dispatchEvent(new CustomEvent("blur")); + options.menuElement.parentElement.remove(); } }); const addOptionElement = options.menuElement.querySelector('[data-type="addOption"]') as HTMLInputElement; diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts index 0740e626a..2f9cd6dcb 100644 --- a/app/src/protyle/render/av/select.ts +++ b/app/src/protyle/render/av/select.ts @@ -101,7 +101,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, if (!menuElement) { return; } - const colId = cellElements ? cellElements[0].dataset.colId : menuElement.firstElementChild.getAttribute("data-col-id"); + const colId = cellElements ? cellElements[0].dataset.colId : menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id"); let name = target.parentElement.dataset.name; let color = target.parentElement.dataset.color; const menu = new Menu("av-col-option", () => { @@ -169,7 +169,17 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, } menu.addItem({ iconHTML: "", - label: `` + label: ``, + bind(element) { + element.querySelector("input").addEventListener("keydown", (event: KeyboardEvent) => { + if (event.isComposing) { + return; + } + if (event.key === "Enter") { + menu.close(); + } + }); + } }); menu.addItem({ label: window.siyuan.languages.delete,