Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): fix colon truncation in PromotedAttributesCard erase handler
hippi345909ee591742a
diff --git a/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx b/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsxindex 38cdcd1909..ad4f1172fd 100644--- a/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx+++ b/apps/client/src/widgets/react/PromotedAttributesCard.spec.tsx@@ -402,6 +402,22 @@ describe("PromotedAttributesCard", () => {expect(mocks.bulk).not.toHaveBeenCalled();expect(mocks.removeOwned).not.toHaveBeenCalled();});++ it("targets the full colon-carrying name when the definition name contains multiple colons", async () => {+ defined = [ definition("label:sometool:parameter") ];+ draw();++ await act(async () => {+ segments()[0].querySelector<HTMLElement>(".promoted-attribute-delete")?.click();+ await flush();+ });++ expect(mocks.bulk).toHaveBeenCalledWith(+ [ "board1" ],+ [ { name: "deleteLabel", labelName: "sometool:parameter" } ],+ { includeDescendants: true, silent: true });+ expect(mocks.removeOwned).toHaveBeenCalledWith(NOTE, "label", "label:sometool:parameter");+ });});describe("creating one", () => {diff --git a/apps/client/src/widgets/react/PromotedAttributesCard.tsx b/apps/client/src/widgets/react/PromotedAttributesCard.tsxindex 6fc23f45f9..a05bdffbe1 100644--- a/apps/client/src/widgets/react/PromotedAttributesCard.tsx+++ b/apps/client/src/widgets/react/PromotedAttributesCard.tsx@@ -198,7 +198,7 @@ export default function PromotedAttributesCard({* panel instead leaves the items carrying values no definition describes.*/const erase = useCallback(async (definitionName: string) => {- const [ type, name ] = definitionName.split(":", 2) as [ "label" | "relation", string ];+ const [ type, name ] = extractAttributeDefinitionTypeAndName(definitionName);await deleteAttributeInSubtree(note.noteId, type, name);await removeOwnedAttributesByNameOrType(note, "label", definitionName);}, [ note ]);