From e393a7edee8b00e758d0fbab4e98a4e987428f10 Mon Sep 17 00:00:00 2001 From: scheinriese Date: Tue, 19 May 2026 13:42:07 +0200 Subject: [PATCH] refactor(block): drop dead block-title-with-icon helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit block-title-with-icon had zero callers — the editor.cljs and property/value.cljs sites that used to compose via this helper were migrated to the explicit 20×20 icon-slot pattern (single icon per row, sourced from get-node-icon-cp), and CMD-K never composed through it. The only remaining references were explanatory comments documenting *why* the new pattern doesn't reuse it. Delete the function and rewrite the four comments to describe the de-dup rule directly (instance rows that diverge from a class default would otherwise render the same icon twice) rather than referencing a dead symbol that would rot future readers. Compile clean. Co-Authored-By: Claude Opus 4.7 --- src/main/frontend/components/cmdk/list_item.cljs | 15 +++++++-------- src/main/frontend/components/editor.cljs | 6 +++--- src/main/frontend/components/property/value.cljs | 13 ++++++------- src/main/frontend/handler/block.cljs | 13 ------------- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/main/frontend/components/cmdk/list_item.cljs b/src/main/frontend/components/cmdk/list_item.cljs index b0fc854002..59a267958c 100644 --- a/src/main/frontend/components/cmdk/list_item.cljs +++ b/src/main/frontend/components/cmdk/list_item.cljs @@ -117,14 +117,13 @@ [:div.text-sm.pb-2.font-bold.text-gray-11 (highlight-query title)]) [:div {:class "cp__cmdk-item-main-text text-sm font-medium text-gray-12 flex items-center gap-2 flex-wrap"} ;; Title only — the icon is already rendered in the dedicated - ;; slot above (lines ~97-109) via the caller's `:icon` prop, - ;; which uses `get-node-icon-cp` to resolve own/inherited icons - ;; consistently. `block-title-with-icon` would have prepended - ;; another `(:logseq.property/icon source-block)` inline, which - ;; for blocks with their own icon override (e.g. an instance row - ;; that diverges from its class default) renders the same icon - ;; twice side-by-side. Inheriting rows hid the bug because the - ;; inline render is nil when the block has no own icon. + ;; slot above via the caller's `:icon` prop (`get-node-icon-cp` + ;; resolves own/inherited icons consistently). Prepending the + ;; block's own `:logseq.property/icon` inline next to the title + ;; would render the same icon twice for instance rows that + ;; diverge from their class default. Inheriting rows would mask + ;; the bug since the inline render is nil when the block has no + ;; own icon. (or (highlight-query text) (:block/title source-block)) text-badge (when info diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index a826e824f5..e70639faad 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -70,9 +70,9 @@ (when-not db-tag? ;; Single icon per row, same policy as CMD-K. `get-node-icon-cp` ;; resolves the committed icon (own → tag default → type default), - ;; so the title text below can render alone — no need to inline - ;; another icon via `block-title-with-icon` (see cmdk/list_item.cljs:114-122 - ;; for the de-dup rationale). + ;; so the title text below can render alone — see cmdk/list_item.cljs + ;; for the de-dup rationale (instance rows that diverge from a class + ;; default would otherwise render the same icon twice). ;; ;; Fixed `w-5 h-5` slot with `justify-center` so 14px tabler glyphs ;; center within a 20px column matching the avatar tile width. All diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index 78ab05d8cf..29925420b8 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -1063,8 +1063,8 @@ ;; Single icon per row, same policy as CMD-K and the ;; bracket popover. `get-node-icon-cp` resolves the ;; committed icon (own → tag default → type default); - ;; the title renders alone below — no inline icon via - ;; `block-title-with-icon` (see cmdk/list_item.cljs:114-122). + ;; the title renders alone below (see cmdk/list_item.cljs + ;; for the de-dup rationale). ;; ;; Fixed 20×20 slot so all titles align regardless of ;; icon type. Stays 20px even when the conditional @@ -1074,11 +1074,10 @@ ;; Class/property pickers intentionally render iconless ;; (the entities being picked ARE classes/properties — a ;; leading icon would just repeat the picker's own context). - ;; The `:logseq.property/classes` check used to be part of - ;; this guard, but only because the old title path inlined - ;; the icon via `block-title-with-icon`; with that path - ;; removed, entity-reference properties (Attendees, - ;; Collaborators, etc.) need the leading icon. + ;; Entity-reference properties (Attendees, Collaborators, + ;; etc.) keep the leading icon — the old title path used + ;; to inline it, but the iconless guard now covers only + ;; class/property to leave entity rows visible. (when-not (contains? #{:class :property} property-type) (icon-component/get-node-icon-cp node {}))] [:div title]]] diff --git a/src/main/frontend/handler/block.cljs b/src/main/frontend/handler/block.cljs index ea98f99367..f777510e09 100644 --- a/src/main/frontend/handler/block.cljs +++ b/src/main/frontend/handler/block.cljs @@ -158,19 +158,6 @@ (when alias (str " -> alias: " alias))))))) -(defn block-title-with-icon - "Used for select item" - [block title icon-cp] - (if-let [icon (:logseq.property/icon block)] - (let [photo? (contains? #{:avatar :image} (:type icon)) - icon-size (if photo? 20 16)] - [:div.flex.flex-row.items-baseline.gap-2 - [:span.icon-inline.self-center.inline-flex.items-center.justify-center.flex-shrink-0 - {:style {:width 20 :height 20}} - (icon-cp icon {:size icon-size :color? true})] - title]) - (or title (:block/title block)))) - (defn edit-block! [block pos & {:keys [_container-id custom-content tail-len save-code-editor?] :or {tail-len 0