From 5ad391eafa21106361e5fe44e4acd1294b55b39b 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 cb0b2b06fd..fad2390920 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -1279,6 +1279,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 2ee3d54f55..37fb791046 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -107,7 +107,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 bbb3007a36..37159b2fd6 100644 --- a/common/test/common_tests/files_changes_test.cljc +++ b/common/test/common_tests/files_changes_test.cljc @@ -11,6 +11,7 @@ [app.common.files.changes-builder :as pcb] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] + [app.common.logic.shapes :as cls] [app.common.schema :as sm] [app.common.schema.generators :as sg] [app.common.schema.test :as smt] @@ -19,6 +20,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.shape :as cts] [app.common.types.tokens-lib :as ctob] @@ -1189,3 +1191,22 @@ {:apply-changes-local-library? true}))] (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)))))