mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 16:30:37 -05:00
🐛 Fix problem moving shapes inside a group inside a layout
This commit is contained in:
parent
9fd6c65d93
commit
89371e10d1
5 changed files with 20 additions and 13 deletions
|
@ -359,7 +359,7 @@
|
|||
|
||||
to-reflow
|
||||
(cond-> to-reflow
|
||||
(and (ctl/layout-child-id? objects current)
|
||||
(and (ctl/layout-descent? objects parent-base)
|
||||
(not= uuid/zero (:frame-id parent-base)))
|
||||
(conj (:frame-id parent-base)))]
|
||||
(recur modif-tree
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.common.types.shape.layout
|
||||
(:require
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.spec :as us]
|
||||
[clojure.spec.alpha :as s]))
|
||||
|
||||
|
@ -99,15 +100,21 @@
|
|||
([shape]
|
||||
(and (= :frame (:type shape)) (= :flex (:layout shape)))))
|
||||
|
||||
(defn layout-child? [objects shape]
|
||||
(defn layout-immediate-child? [objects shape]
|
||||
(let [parent-id (:parent-id shape)
|
||||
parent (get objects parent-id)]
|
||||
(layout? parent)))
|
||||
|
||||
(defn layout-immediate-child-id? [objects id]
|
||||
(let [parent-id (dm/get-in objects [id :parent-id])
|
||||
parent (get objects parent-id)]
|
||||
(layout? parent)))
|
||||
|
||||
(defn layout-descent? [objects shape]
|
||||
(let [frame-id (:frame-id shape)
|
||||
frame (get objects frame-id)]
|
||||
(layout? frame)))
|
||||
|
||||
(defn layout-child-id? [objects id]
|
||||
(let [shape (get objects id)]
|
||||
(layout-child? objects shape)))
|
||||
|
||||
(defn inside-layout?
|
||||
"Check if the shape is inside a layout"
|
||||
[objects shape]
|
||||
|
|
|
@ -440,7 +440,7 @@
|
|||
exclude-frames-siblings
|
||||
(into exclude-frames
|
||||
(comp (mapcat (partial cph/get-siblings-ids objects))
|
||||
(filter (partial ctl/layout-child-id? objects)))
|
||||
(filter (partial ctl/layout-immediate-child-id? objects)))
|
||||
selected)
|
||||
|
||||
fix-axis
|
||||
|
@ -640,7 +640,7 @@
|
|||
(let [objects (wsh/lookup-page-objects state)
|
||||
selected (wsh/lookup-selected state {:omit-blocked? true})
|
||||
selected-shapes (->> selected (map (d/getf objects)))]
|
||||
(if (every? (partial ctl/layout-child? objects) selected-shapes)
|
||||
(if (every? (partial ctl/layout-immediate-child-id? objects) selected-shapes)
|
||||
(rx/of (reorder-selected-layout-child direction))
|
||||
(rx/of (nudge-selected-shapes direction shift?)))))))
|
||||
|
||||
|
|
|
@ -402,7 +402,7 @@
|
|||
(let [objects (wsh/lookup-page-objects state)]
|
||||
(into []
|
||||
(comp (map (d/getf objects))
|
||||
(filter (partial ctl/layout-child? objects)))
|
||||
(filter (partial ctl/layout-immediate-child? objects)))
|
||||
ids)))
|
||||
st/state =))
|
||||
|
||||
|
@ -481,7 +481,7 @@
|
|||
(fn [objects]
|
||||
(->> ids
|
||||
(map (d/getf objects))
|
||||
(some (partial ctl/layout-child? objects))))
|
||||
(some (partial ctl/layout-immediate-child? objects))))
|
||||
workspace-page-objects))
|
||||
|
||||
(defn get-flex-child-viewer
|
||||
|
@ -491,7 +491,7 @@
|
|||
(let [objects (wsh/lookup-viewer-objects state page-id)]
|
||||
(into []
|
||||
(comp (map (d/getf objects))
|
||||
(filter (partial ctl/layout-child? objects)))
|
||||
(filter (partial ctl/layout-immediate-child? objects)))
|
||||
ids)))
|
||||
st/state =))
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
grid-y-data (get-grids-snap-points frame :y)]
|
||||
|
||||
(cond-> page-data
|
||||
(not (ctl/layout-child? objects frame))
|
||||
(not (ctl/layout-descent? objects frame))
|
||||
|
||||
(-> ;; Update root frame information
|
||||
(assoc-in [uuid/zero :objects-data frame-id] frame-data)
|
||||
|
@ -106,7 +106,7 @@
|
|||
:id (:id shape)
|
||||
:pt %)))]
|
||||
(cond-> page-data
|
||||
(not (ctl/layout-child? objects shape))
|
||||
(not (ctl/layout-descent? objects shape))
|
||||
(-> (assoc-in [frame-id :objects-data (:id shape)] shape-data)
|
||||
(update-in [frame-id :x] (make-insert-tree-data shape-data :x))
|
||||
(update-in [frame-id :y] (make-insert-tree-data shape-data :y))))))
|
||||
|
|
Loading…
Reference in a new issue