From 2d45cba36c63727865c87bad41f1cfb99051cae8 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 20 Oct 2025 19:13:04 +0200 Subject: [PATCH] :bug: Fix Restoring a variant from another file makes it overlap --- .../app/main/data/workspace/libraries.cljs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 597518eeac..e116393683 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -698,7 +698,7 @@ ;; that will be selected and zoomed along the main one ;; update-layout? indicates if it should send a :layout/update event ;; for the parents of the component - [& {:keys [id additional-ids update-layout?] :as options}] + [& {:keys [id additional-ids update-layout? retries] :or {retries 0} :as options}] (ptk/reify ::go-to-local-component ptk/WatchEvent (watch [_ state stream] @@ -709,15 +709,17 @@ select-and-zoom (fn [ids] (let [parent-ids (when update-layout? - (map #(-> (get objects %) :parent-id) ids))] - (rx/concat - (rx/of - (dws/select-shapes ids) - dwz/zoom-to-selected-shape) - (when update-layout? - (->> (rx/of (ptk/data-event :layout/update {:ids parent-ids})) - ;; Delay so the navigation can finish - (rx/delay 250)))))) + (keep #(-> (get objects %) :parent-id) ids))] + + (if (and update-layout? (empty? parent-ids) (< retries 8)) + ;; The objects are not loaded yet, wait and try again + (->> (rx/of (go-to-local-component (assoc options :retries (inc retries)))) + (rx/delay 250)) + (rx/concat + (rx/of (dws/select-shapes ids) + dwz/zoom-to-selected-shape) + (when update-layout? + (rx/of (ptk/data-event :layout/update {:ids parent-ids}))))))) redirect-to-page (fn [page-id ids]