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(attributes): let a right press ask what can be done without picking the row out
Elian Doran11882ccb94ff
diff --git a/apps/client/src/widgets/sidebar/AttributeList.spec.tsx b/apps/client/src/widgets/sidebar/AttributeList.spec.tsxindex 48ca1e1362..9d36198753 100644--- a/apps/client/src/widgets/sidebar/AttributeList.spec.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.spec.tsx@@ -989,7 +989,22 @@ describe("AttributeList", () => {const [ , saved ] = put.mock.calls[0] as [ string, Attribute[] ];expect(saved.map((attribute) => attribute.name)).toEqual([ "template", "label:priority" ]);- // A right press on a row outside them narrows down to that row alone.+ // Deleting the lot let them all go, so nothing is picked out now — and a right press then+ // picks nothing out for itself: it is a press asking what can be done to the row under it,+ // not one picking that row out, and picking it would turn the whole panel over to the+ // standing rows are picked out in, bar and checkboxes and all, for a menu about one row.+ expect(selectedNames()).toEqual([]);+ rightPress(0);+ expect(selectedNames()).toEqual([]);+ expect(container.querySelector(".attribute-selection-bar")).toBeNull();+ expect(container.querySelector(".attribute-list-panel")?.className).not.toContain("selecting");+ // The menu is about the row pressed all the same, which is the point of the press.+ expect(menuItem("bx bx-copy")).toBeDefined();+ expect(menuItem("bx bx-trash")).toBeDefined();++ // With rows picked out, though, a right press outside them narrows down to that row alone:+ // what the menu acts on has to be what the panel shows as picked.+ pick(1, { ctrlKey: true });rightPress(0);expect(selectedNames()).toEqual([ "template" ]);// An inherited row is the source note's to delete, so only copying is offered over it.diff --git a/apps/client/src/widgets/sidebar/AttributeList.tsx b/apps/client/src/widgets/sidebar/AttributeList.tsxindex 0fa30d6d29..1d756aa967 100644--- a/apps/client/src/widgets/sidebar/AttributeList.tsx+++ b/apps/client/src/widgets/sidebar/AttributeList.tsx@@ -494,8 +494,19 @@ export default function AttributeList() {if (!attributeId || !selection.has(attributeId)) {picked = [ attribute ];- selectionAnchor.current = attributeId ?? null;- setSelection(attributeId ? new Set([ attributeId ]) : EMPTY_SELECTION);++ // The narrowing is only a correction, so it is only made where there is something to+ // correct: with rows already picked out, a menu about a row outside them would leave+ // the panel offering to copy three rows while the menu deleted a fourth. With none+ // picked out there is no such contradiction — and picking this one out to make the+ // point would turn the whole panel over to a standing it was never asked for, every row+ // grown a checkbox and stripped of its own buttons, the bar up at the foot, all for a+ // menu about the one row under the pointer. A press asking what can be done to a row is+ // not a press picking it out.+ if (isSelecting) {+ selectionAnchor.current = attributeId ?? null;+ setSelection(attributeId ? new Set([ attributeId ]) : EMPTY_SELECTION);+ }}const items: MenuItem<never>[] = [