From 1240f3abdc430e0cfca7e3591c6a4ea4227f063d Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 30 Sep 2026 17:13:04 +0200 Subject: [PATCH] :bug: Skip update-shapes validation when changes have no page generate-update-shapes only validates changes made on a page, and it checked that with (and page-id ...) after pcb/get-page-id. The getter now asserts that a page-id was given, so the check could never be false and changes on a component container would fail on the assert instead of skipping the validation. Add pcb/has-page-id? and check it before calling the getter. AI-assisted-by: claude-opus-5-5 --- .../src/app/common/files/changes_builder.cljc | 4 ++++ common/src/app/common/logic/shapes.cljc | 4 +++- .../test/common_tests/files_changes_test.cljc | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/files/changes_builder.cljc b/common/src/app/common/files/changes_builder.cljc index 9ea2b0c11a..a42e1dcedb 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -1293,6 +1293,10 @@ [changes] (contains? (meta changes) ::page)) +(defn has-page-id? + [changes] + (contains? (meta changes) ::page-id)) + (defn set-text-content [changes id content prev-content] (assert-page-id! changes) diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index 552e57c385..56408cc7df 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -108,7 +108,9 @@ (not ignore-touched) (generate-unapply-tokens objects changed-sub-attr changed-item-index)) - page-id (pcb/get-page-id changes) + ;; Only validate changes on a page (not on a component container) + page-id (when (pcb/has-page-id? changes) + (pcb/get-page-id changes)) modified-components (ctn/get-all-instance-roots objects ids) changes (if (and page-id (seq modified-components)) diff --git a/common/test/common_tests/files_changes_test.cljc b/common/test/common_tests/files_changes_test.cljc index 89e331089f..ca73e9b020 100644 --- a/common/test/common_tests/files_changes_test.cljc +++ b/common/test/common_tests/files_changes_test.cljc @@ -13,6 +13,7 @@ [app.common.files.helpers :as cfh] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] + [app.common.logic.shapes :as cls] [app.common.math :as mth] [app.common.schema :as sm] [app.common.schema.generators :as sg] @@ -22,6 +23,7 @@ [app.common.test-helpers.files :as thf] [app.common.test-helpers.shapes :as ths] [app.common.time :as ct] + [app.common.types.container :as ctn] [app.common.types.file :as ctf] [app.common.types.page :as ctp] [app.common.types.shape :as cts] @@ -1623,3 +1625,22 @@ (t/is (= 2 (count (:redo-changes changes)))))) +(t/deftest update-shapes-without-page-skips-validation + ;; generate-update-shapes only validates when the changes have a page. For + ;; changes on a component container it must not fail on the page-id getter. + (let [file (-> (thf/sample-file :file1) + (tho/add-simple-component :c01 :m01 :r01)) + page (thf/current-page file) + main (ths/get-shape file :m01) + comp (thc/get-component file :c01) + + changes (cls/generate-update-shapes (-> (pcb/empty-changes nil) + (pcb/with-container (ctn/make-container comp :component))) + [(:id main)] + #(assoc % :name "New name") + (:objects page) + {})] + + (t/is (seq (:redo-changes changes))) + (t/is (not-any? #(= :validate-shapes (:type %)) (:redo-changes changes))))) +