From 5b1766835ff395f82e5b7a286b25474690d661c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Wed, 21 Jan 2026 09:26:48 +0100 Subject: [PATCH] :bug: Fix broken selection on duplicated shapes on new pages --- frontend/src/app/render_wasm/shape.cljs | 10 ++++++++-- frontend/src/app/worker/index.cljs | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/render_wasm/shape.cljs b/frontend/src/app/render_wasm/shape.cljs index 6475fb9e2f..7809d5ca0f 100644 --- a/frontend/src/app/render_wasm/shape.cljs +++ b/frontend/src/app/render_wasm/shape.cljs @@ -227,7 +227,7 @@ :svg-attrs (do (api/set-shape-svg-attrs v) - ;; Always update fills/blur/shadow to clear previous state if filters disappear + ;; Always update fills/blur/shadow to clear previous state if filters disappear (api/set-shape-fills id (:fills shape) false) (api/set-shape-blur (:blur shape)) (api/set-shape-shadows (:shadow shape))) @@ -397,12 +397,18 @@ (next es)) (throw (js/Error. "conj on a map takes map entries or seqables of map entries")))))))) +(def ^:private xf:without-id-and-type + (remove (fn [kvpair] + (let [k (key kvpair)] + (or (= k :id) + (= k :type)))))) + (defn create-shape "Instanciate a shape from a map" [attrs] (ShapeProxy. (:id attrs) (:type attrs) - (dissoc attrs :id :type))) + (into {} xf:without-id-and-type attrs))) (t/add-handlers! ;; We only add a write handler, read handler uses the dynamic dispatch diff --git a/frontend/src/app/worker/index.cljs b/frontend/src/app/worker/index.cljs index 0de440f7c1..c40f0b6fd8 100644 --- a/frontend/src/app/worker/index.cljs +++ b/frontend/src/app/worker/index.cljs @@ -58,6 +58,8 @@ (swap! state update ::snap snap/update-page old-page new-page) (swap! state update ::selection selection/update-page old-page new-page)) + (catch :default cause + (log/error :hint "error updating page index" :id page-id :cause cause)) (finally (let [elapsed (tpoint)] (log/dbg :hint "page index updated" :id page-id :elapsed elapsed ::log/sync? true))))