From cf24914e6c60f30e1c52df8bb3d27ed9168f5e54 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 13 May 2026 11:40:58 +0800 Subject: [PATCH] fix: dedupe raw node choices --- src/main/frontend/components/property/value.cljs | 8 +++++--- src/test/frontend/components/property/value_test.cljs | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index 59458120cc..32c9b307e5 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -674,9 +674,11 @@ (defn- add-initial-node-choice [initial-choices new-choice] - (let [node-choice-match? (fn [choice] - (let [choice-value (:value choice) - new-value (:value new-choice)] + (let [choice-node-value (fn [choice] + (or (:value choice) choice)) + node-choice-match? (fn [choice] + (let [choice-value (choice-node-value choice) + new-value (choice-node-value new-choice)] (or (and (:db/id choice-value) (= (:db/id choice-value) (:db/id new-value))) (and (:block/uuid choice-value) (= (:block/uuid choice-value) (:block/uuid new-value))) diff --git a/src/test/frontend/components/property/value_test.cljs b/src/test/frontend/components/property/value_test.cljs index a67318c083..37ea235e54 100644 --- a/src/test/frontend/components/property/value_test.cljs +++ b/src/test/frontend/components/property/value_test.cljs @@ -84,6 +84,16 @@ (is (= [existing] (#'property-value/add-initial-node-choice [existing] duplicate))))) +(deftest add-initial-node-choice-dedupes-existing-raw-entity-test + (let [existing {:db/id 100 + :block/uuid #uuid "11111111-1111-1111-1111-111111111111" + :block/title "Existing node"} + duplicate {:value {:db/id 100 + :block/uuid #uuid "11111111-1111-1111-1111-111111111111"} + :label "Existing node"}] + (is (= [existing] + (#'property-value/add-initial-node-choice [existing] duplicate))))) + (deftest add-initial-node-choice-keeps-distinct-node-with-same-label-test (let [existing {:value {:db/id 100 :block/uuid #uuid "11111111-1111-1111-1111-111111111111"}