🐛 Fix Restoring a variant from another file makes it overlap

This commit is contained in:
Pablo Alba
2025-10-20 19:13:04 +02:00
committed by Pablo Alba
parent cf21ffb30f
commit 2d45cba36c

View File

@@ -698,7 +698,7 @@
;; that will be selected and zoomed along the main one ;; that will be selected and zoomed along the main one
;; update-layout? indicates if it should send a :layout/update event ;; update-layout? indicates if it should send a :layout/update event
;; for the parents of the component ;; 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/reify ::go-to-local-component
ptk/WatchEvent ptk/WatchEvent
(watch [_ state stream] (watch [_ state stream]
@@ -709,15 +709,17 @@
select-and-zoom select-and-zoom
(fn [ids] (fn [ids]
(let [parent-ids (when update-layout? (let [parent-ids (when update-layout?
(map #(-> (get objects %) :parent-id) ids))] (keep #(-> (get objects %) :parent-id) ids))]
(rx/concat
(rx/of (if (and update-layout? (empty? parent-ids) (< retries 8))
(dws/select-shapes ids) ;; The objects are not loaded yet, wait and try again
dwz/zoom-to-selected-shape) (->> (rx/of (go-to-local-component (assoc options :retries (inc retries))))
(when update-layout? (rx/delay 250))
(->> (rx/of (ptk/data-event :layout/update {:ids parent-ids})) (rx/concat
;; Delay so the navigation can finish (rx/of (dws/select-shapes ids)
(rx/delay 250)))))) dwz/zoom-to-selected-shape)
(when update-layout?
(rx/of (ptk/data-event :layout/update {:ids parent-ids})))))))
redirect-to-page redirect-to-page
(fn [page-id ids] (fn [page-id ids]