diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts index 888d94578..392855dff 100644 --- a/app/src/protyle/render/av/openMenuPanel.ts +++ b/app/src/protyle/render/av/openMenuPanel.ts @@ -1184,6 +1184,8 @@ export const openMenuPanel = (options: { event.stopPropagation(); break; } else if (type === "setRelationCell") { + menuElement.querySelector(".b3-menu__item--current")?.classList.remove("b3-menu__item--current"); + target.classList.add("b3-menu__item--current"); setRelationCell(options.protyle, options.blockElement as HTMLElement, target, options.cellElements); event.preventDefault(); event.stopPropagation(); diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts index c2798471d..880449564 100644 --- a/app/src/protyle/render/av/relation.ts +++ b/app/src/protyle/render/av/relation.ts @@ -207,7 +207,7 @@ export const toggleUpdateRelationBtn = (menuItemsElement: HTMLElement, avId: str } }; -const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, isDetached?: boolean, text?: string) => { +const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, isDetached?: boolean, text?: string, className?: string) => { if (type === "selected") { return ` ${text} @@ -224,7 +224,7 @@ const genSelectItemHTML = (type: "selected" | "empty" | "unselect", id?: string, `; } if (type == "unselect") { - return ``; @@ -392,7 +392,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar newValue.blockIDs.splice(removeIndex, 1); newValue.contents.splice(removeIndex, 1); separatorElement.after(target); - target.outerHTML = genSelectItemHTML("unselect", targetId, !target.querySelector(".popover__block"), Lute.EscapeHTMLStr(target.querySelector(".b3-menu__label").textContent)); + target.outerHTML = genSelectItemHTML("unselect", targetId, !target.querySelector(".popover__block"), Lute.EscapeHTMLStr(target.querySelector(".b3-menu__label").textContent), target.className); } else if (targetId) { newValue.blockIDs.push(targetId); newValue.contents.push({ @@ -404,7 +404,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar isDetached: !target.firstElementChild.getAttribute("style") }); separatorElement.before(target); - target.outerHTML = ``; if (!separatorElement.nextElementSibling) { separatorElement.insertAdjacentHTML("afterend", genSelectItemHTML("empty")); @@ -438,10 +438,8 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelector isDetached: true }); separatorElement.insertAdjacentHTML("beforebegin", ``); +class="${target.className} ariaLabel" draggable="true">${genSelectItemHTML("selected", rowId, true, Lute.EscapeHTMLStr(content))}`); } - menuElement.querySelector(".b3-menu__item--current")?.classList.remove("b3-menu__item--current"); - menuElement.querySelector(".b3-menu__items .b3-menu__item:not(.fn__none)").classList.add("b3-menu__item--current"); } updateCellsValue(protyle, nodeElement, newValue, cellElements); };