From 5a2d982d0441ae799e7a78e0bd5ce3257ff2a95d Mon Sep 17 00:00:00 2001 From: Elena Torro Date: Mon, 4 May 2026 17:48:32 +0200 Subject: [PATCH] :zap: Skip grid reorder and changed-attrs walk on translation commits --- common/src/app/common/logic/shapes.cljc | 22 ++++++++++++------- .../src/app/main/data/workspace/shapes.cljs | 14 +++++++++--- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index f350913987..253304de65 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -75,7 +75,7 @@ (reduce check-shape changes mod-obj-changes))) (defn generate-update-shapes - [changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects?]}] + [changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects? translation?]}] (let [changes (reduce (fn [changes id] (let [opts {:attrs attrs @@ -86,13 +86,19 @@ (-> changes (pcb/with-objects objects)) ids) - grid-ids (->> ids (filter (partial ctl/grid-layout? objects))) - changes (-> changes - (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true}) - (pcb/reorder-grid-children ids) - (cond-> - (not ignore-touched) - (generate-unapply-tokens objects changed-sub-attr)))] + ;; Translation doesn't shift children between grid cells, so + ;; cell reassignment + child reorder are no-ops with a per-grid + ;; cost. Skipping them on translation-only commits removes the + ;; grid-layout reflow from the on-drop hot path. + grid-ids (when-not translation? + (->> ids (filter (partial ctl/grid-layout? objects)))) + changes (cond-> changes + (seq grid-ids) + (-> (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true}) + (pcb/reorder-grid-children ids)) + + (not ignore-touched) + (generate-unapply-tokens objects changed-sub-attr))] changes)) (defn- generate-update-shape-flags diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index dbfc1291c9..a3e6bcb8d0 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -73,9 +73,16 @@ (filter #(some update-layout-attr? (pcb/changed-attrs % objects update-fn {:attrs attrs :with-objects? with-objects?}))) (map :id)) + ;; `xf-update-layout` runs `update-fn` + attr diff for + ;; every id just to decide whether to dispatch + ;; `:layout/update`. `update-layout-attr?` is `#{:hidden}`, + ;; so a pure-translation commit can never trigger it — + ;; skip the N×diff walk on drop-of-layout-drag (the hot + ;; on-drop path for layouts with many children). update-layout-ids - (->> (into [] xf-update-layout ids) - (not-empty)) + (when-not translation? + (->> (into [] xf-update-layout ids) + (not-empty))) changes (-> (pcb/empty-changes it page-id) @@ -88,7 +95,8 @@ :changed-sub-attr changed-sub-attr :ignore-tree ignore-tree :ignore-touched ignore-touched - :with-objects? with-objects?}) + :with-objects? with-objects? + :translation? translation?}) (cond-> undo-group (pcb/set-undo-group undo-group)) (pcb/set-translation? translation?))