From d308980ad47415d947aef733c4883da093645d6f Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 9 Dec 2025 16:16:41 +0100 Subject: [PATCH] :bug: Add validation for more instances of missing swap slot --- CHANGES.md | 1 + common/src/app/common/files/validate.cljc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 54df8056ee..34c7fb8b60 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -93,6 +93,7 @@ example. It's still usable as before, we just removed the example. - Fix unpublish library modal not scrolling a long file list [Taiga #12285](https://tree.taiga.io/project/penpot/issue/12285) - Fix incorrect interaction betwen hower and scroll on assets sidebar [Taiga #12389](https://tree.taiga.io/project/penpot/issue/12389) - Fix switch variants with paths [Taiga #12841](https://tree.taiga.io/project/penpot/issue/12841) +- Fix missing validation for for some instances of missing swap slot [Taiga #12703](https://tree.taiga.io/project/penpot/issue/12703) ## 2.11.1 diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 5b0e1d74d4..51a6192cd3 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -326,6 +326,23 @@ :component-file (:component-file ref-shape) :component-id (:component-id ref-shape))))) + +(defn- check-diff-comp-missing-slot + "Validate that if this shape points to a different component than its referenced shape, is has a swap slot" + [shape file page libraries] + (let [ref-shape (ctf/find-ref-shape file page libraries shape :include-deleted? true)] + (when (and (some? ref-shape) + (not= (:component-id ref-shape) (:component-id shape)) + (nil? (ctk/get-swap-slot shape))) + (report-error :missing-slot + (str/ffmt "Referenced shape % points to a different component, so this shape must have been swapped. Should have swap slot" (:shape-ref shape)) + shape file page + :swap-slot (or (ctk/get-swap-slot ref-shape) (:id ref-shape)) + :component-file (:component-file shape) + :component-id (:component-id shape) + :ref-component-file (:component-file ref-shape) + :ref-component-id (:component-id ref-shape))))) + (defn- check-empty-swap-slot "Validate that this shape does not have any swap slot." [shape file page] @@ -418,8 +435,10 @@ (check-component-not-main-head shape file page libraries) (check-component-not-root shape file page) (check-valid-touched shape file page) + (check-diff-comp-missing-slot shape file page libraries) ;; We can have situations where the nested copy and the ancestor copy come from different libraries and some of them have been dettached ;; so we only validate the shape-ref if the ancestor is from a valid library + ;; TODO library-exists is missing on the stack calls for items inside frames (when library-exists (check-component-ref shape file page libraries) (check-ref-is-head shape file page libraries))