mirror of
https://github.com/penpot/penpot.git
synced 2025-05-09 06:05:53 +02:00
🐛 Fix problems when moving shapes in layouts
This commit is contained in:
parent
b6be1c2e1a
commit
c17d2c1aba
2 changed files with 16 additions and 9 deletions
|
@ -428,12 +428,14 @@
|
||||||
comps-nesting-loop?)))
|
comps-nesting-loop?)))
|
||||||
|
|
||||||
(defn find-valid-parent-and-frame-ids
|
(defn find-valid-parent-and-frame-ids
|
||||||
"Navigate trough the ancestors until find one that is valid"
|
"Navigate trough the ancestors until find one that is valid. Returns [ parent-id frame-id ]"
|
||||||
[parent-id objects children]
|
[parent-id objects children]
|
||||||
(let [parent (get objects parent-id)]
|
(letfn [(get-frame [parent-id]
|
||||||
(if (invalid-structure-for-component? objects parent children)
|
(if (cfh/frame-shape? objects parent-id) parent-id (get-in objects [parent-id :frame-id])))]
|
||||||
(find-valid-parent-and-frame-ids (:parent-id parent) objects children)
|
(let [parent (get objects parent-id)
|
||||||
[parent-id
|
;; We can always move the children to the parent they already have
|
||||||
(if (= :frame (:type parent))
|
no-changes?
|
||||||
parent-id
|
(->> children (every? #(= parent-id (:parent-id %))))]
|
||||||
(:frame-id parent))])))
|
(if (or no-changes? (not (invalid-structure-for-component? objects parent children)))
|
||||||
|
[parent-id (get-frame parent-id)]
|
||||||
|
(recur (:parent-id parent) objects children)))))
|
||||||
|
|
|
@ -511,7 +511,11 @@
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state {:omit-blocked? true})
|
selected (wsh/lookup-selected state {:omit-blocked? true})
|
||||||
ids (if (nil? ids) selected ids)
|
ids (if (nil? ids) selected ids)
|
||||||
shapes (mapv #(get objects %) ids)
|
shapes (into []
|
||||||
|
(comp (map (d/getf objects))
|
||||||
|
(remove ctk/in-component-copy-not-head?))
|
||||||
|
ids)
|
||||||
|
|
||||||
duplicate-move-started? (get-in state [:workspace-local :duplicate-move-started?] false)
|
duplicate-move-started? (get-in state [:workspace-local :duplicate-move-started?] false)
|
||||||
|
|
||||||
stopper (->> stream
|
stopper (->> stream
|
||||||
|
@ -670,6 +674,7 @@
|
||||||
|
|
||||||
{:keys [layout-grid-cells]}
|
{:keys [layout-grid-cells]}
|
||||||
(->> children
|
(->> children
|
||||||
|
(remove #(ctk/in-component-copy-not-head? (get objects %)))
|
||||||
(keep #(ctl/get-cell-by-shape-id parent %))
|
(keep #(ctl/get-cell-by-shape-id parent %))
|
||||||
(sort-by key-prop key-comp)
|
(sort-by key-prop key-comp)
|
||||||
(reduce (fn [parent {:keys [id row column row-span column-span]}]
|
(reduce (fn [parent {:keys [id row column row-span column-span]}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue