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
client/collections/board: hide the create column input field button while there is no title typed yet
Adorian Doranef40771ea2f4
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsxindex b4fac8889f..d24cdb2a79 100644--- a/apps/client/src/widgets/collections/board/index.spec.tsx+++ b/apps/client/src/widgets/collections/board/index.spec.tsx@@ -1550,10 +1550,14 @@ describe("Board column rename", () => {});const editor = slot?.querySelector<HTMLInputElement>("input");- const button = slot?.querySelector<HTMLElement>(".title-editor-submit");- if (!editor || !button) throw new Error("expected the editor and its button");+ if (!editor) throw new Error("expected the add-column editor to be open");++ // Nothing typed is nothing to create, so there is no button standing there at all.+ expect(slot?.querySelector(".title-editor-submit")).toBeNull();await type(editor, "Blocked");+ const button = slot?.querySelector<HTMLElement>(".title-editor-submit");+ if (!button) throw new Error("expected the button beside the field");button.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true }));const opened = show.mock.calls.at(-1)?.[0];diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex faf4273afb..2b6a9cd2e5 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -1044,12 +1044,14 @@ export function TitleEditor({return field;}- // A placement applies only to the button that creates. With nothing typed, the button- // stands for whatever the caller offers instead.+ // A placement applies only to the button that creates. With nothing typed there is nothing+ // to create, so the button stands for whatever the caller offers instead, or for nothing.const offersPlacement = !!openPlacements && !isEmpty;const madeBy = submitTitle ?? t("board_view.add-new-item");- const offered = isEmpty && whenEmpty- ? { icon: "bx bx-folder-open", title: whenEmpty.title, onClick: whenEmpty.onClick }+ const offered = isEmpty+ ? whenEmpty && {+ icon: "bx bx-folder-open", title: whenEmpty.title, onClick: whenEmpty.onClick+ }: {icon: "bx bx-plus-circle",title: offersPlacement@@ -1064,23 +1066,26 @@ export function TitleEditor({{field}{/* The press must not take focus out of the field first: losing it is what closesthe editor, and it would be gone before the click arrived. */}- <span- onMouseDown={(e) => e.preventDefault()}- onPointerDown={offersPlacement ? holdToPlace : undefined}- onPointerUp={cancelHold}- onPointerMove={holdMoved}- onPointerCancel={cancelHold}- onContextMenu={offersPlacement ? openPlacementMenu : undefined}- >- <ActionButton- className="title-editor-submit"- icon={offered.icon}- text={offered.title}- tooltipHtml={offersPlacement}- tooltipClass={offersPlacement ? "title-editor-submit-tooltip" : undefined}- onClick={offered.onClick}- />- </span>+ {offered && (+ <span+ onMouseDown={(e) => e.preventDefault()}+ onPointerDown={offersPlacement ? holdToPlace : undefined}+ onPointerUp={cancelHold}+ onPointerMove={holdMoved}+ onPointerCancel={cancelHold}+ onContextMenu={offersPlacement ? openPlacementMenu : undefined}+ >+ <ActionButton+ className="title-editor-submit"+ icon={offered.icon}+ text={offered.title}+ tooltipHtml={offersPlacement}+ tooltipClass={+ offersPlacement ? "title-editor-submit-tooltip" : undefined}+ onClick={offered.onClick}+ />+ </span>+ )}</div>);}