diff --git a/common/src/app/common/files/repair.cljc b/common/src/app/common/files/repair.cljc index 016e18769..c9f583a92 100644 --- a/common/src/app/common/files/repair.cljc +++ b/common/src/app/common/files/repair.cljc @@ -72,7 +72,7 @@ (fn [parent-shape] ; Remove child shape from children list (log/debug :hint " -> Remove child " :child-id (:child-id args)) - (update parent-shape :shapes d/removev #(= % (:child-id args))))] + (update parent-shape :shapes (partial d/removev #(= % (:child-id args)))))] (log/info :hint "Repairing shape :child-not-found" :id (:id shape) :name (:name shape) :page-id page-id) (-> (pcb/empty-changes nil page-id) diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 2d7b27b55..537882e11 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -64,7 +64,7 @@ (def ^:dynamic *errors* nil) (defn report-error! - [code hint shape file page & args] + [code hint shape file page & {:as args}] (if (some? *errors*) (vswap! *errors* conj {:code code :hint hint @@ -122,11 +122,12 @@ shape file page))) (doseq [child-id (:shapes shape)] - (when (nil? (ctst/get-shape page child-id)) - (report-error! :child-not-found - (str/ffmt "Child % not found" child-id) - shape file page - :child-id child-id))))))) + (let [child (ctst/get-shape page child-id)] + (when (or (nil? child) (not= (:parent-id child) (:id shape))) + (report-error! :child-not-found + (str/ffmt "Child % not found" child-id) + shape file page + :child-id child-id)))))))) (defn validate-frame! "Validate that the frame-id shape exists and is indeed a frame. Also