mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 12:01:38 +02:00
Merge pull request #2131 from penpot/andrewzhurov-3932-layers-get-out-of-the-group-when-moved
🐛 Fix layers get out of the group when moved
This commit is contained in:
commit
1df9f0b29e
6 changed files with 28 additions and 37 deletions
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
- Fix unexpected removal of guides on copy&paste frames [Taiga #3887](https://tree.taiga.io/project/penpot/issue/3887) by @andrewzhurov
|
- Fix unexpected removal of guides on copy&paste frames [Taiga #3887](https://tree.taiga.io/project/penpot/issue/3887) by @andrewzhurov
|
||||||
- Fix props preserving on copy&paste texts [Taiga #3629](https://tree.taiga.io/project/penpot/issue/3629) by @andrewzhurov
|
- Fix props preserving on copy&paste texts [Taiga #3629](https://tree.taiga.io/project/penpot/issue/3629) by @andrewzhurov
|
||||||
|
- Fix unexpected layers ungrouping on moving it [Taiga #3932](https://tree.taiga.io/project/penpot/issue/3932) by @andrewzhurov
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -23,19 +23,13 @@
|
||||||
(and (= type :frame) (= id uuid/zero)))
|
(and (= type :frame) (= id uuid/zero)))
|
||||||
|
|
||||||
(defn root-frame?
|
(defn root-frame?
|
||||||
([objects id]
|
[{:keys [frame-id type]}]
|
||||||
(root-frame? (get objects id)))
|
|
||||||
|
|
||||||
([{:keys [frame-id type]}]
|
|
||||||
(and (= type :frame)
|
(and (= type :frame)
|
||||||
(= frame-id uuid/zero))))
|
(= frame-id uuid/zero)))
|
||||||
|
|
||||||
(defn frame-shape?
|
(defn frame-shape?
|
||||||
([objects id]
|
[{:keys [type]}]
|
||||||
(frame-shape? (get objects id)))
|
(= type :frame))
|
||||||
|
|
||||||
([{:keys [type]}]
|
|
||||||
(= type :frame)))
|
|
||||||
|
|
||||||
(defn group-shape?
|
(defn group-shape?
|
||||||
[{:keys [type]}]
|
[{:keys [type]}]
|
||||||
|
|
|
@ -161,13 +161,15 @@
|
||||||
(cond
|
(cond
|
||||||
(= base base-shape-id)
|
(= base base-shape-id)
|
||||||
(and (not top-frames?)
|
(and (not top-frames?)
|
||||||
(cph/frame-shape? objects base-shape-id)
|
(let [object (get objects base-shape-id)]
|
||||||
(cph/root-frame? objects base-shape-id))
|
(or (cph/frame-shape? object)
|
||||||
|
(cph/root-frame? object))))
|
||||||
|
|
||||||
(= base over-shape-id)
|
(= base over-shape-id)
|
||||||
(or top-frames?
|
(or top-frames?
|
||||||
(not (cph/frame-shape? objects over-shape-id))
|
(let [object (get objects over-shape-id)]
|
||||||
(not (cph/root-frame? objects over-shape-id)))
|
(or (not (cph/frame-shape? object))
|
||||||
|
(not (cph/root-frame? object)))))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(< index-a index-b))))
|
(< index-a index-b))))
|
||||||
|
|
|
@ -739,14 +739,6 @@
|
||||||
(rx/of (set-modifiers [id] {:displacement displ} false true)
|
(rx/of (set-modifiers [id] {:displacement displ} false true)
|
||||||
(apply-modifiers))))))
|
(apply-modifiers))))))
|
||||||
|
|
||||||
(defn check-frame-move?
|
|
||||||
[target-frame-id objects position shape]
|
|
||||||
|
|
||||||
(let [current-frame (get objects (:frame-id shape))]
|
|
||||||
;; If the current frame contains the point and it's a child of the target
|
|
||||||
(and (gsh/has-point? current-frame position)
|
|
||||||
(cph/is-child? objects target-frame-id (:id current-frame)))))
|
|
||||||
|
|
||||||
(defn- calculate-frame-for-move
|
(defn- calculate-frame-for-move
|
||||||
[ids]
|
[ids]
|
||||||
(ptk/reify ::calculate-frame-for-move
|
(ptk/reify ::calculate-frame-for-move
|
||||||
|
@ -756,18 +748,19 @@
|
||||||
page-id (:current-page-id state)
|
page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
frame-id (ctt/frame-id-by-position objects position)
|
frame-id (ctt/frame-id-by-position objects position)
|
||||||
|
lookup (d/getf objects)
|
||||||
|
|
||||||
moving-shapes
|
moving-shapes
|
||||||
(->> ids
|
(->> ids
|
||||||
(cph/clean-loops objects)
|
(cph/clean-loops objects)
|
||||||
(keep #(get objects %))
|
(keep (d/getf objects))
|
||||||
(remove (partial check-frame-move? frame-id objects position)))
|
(remove #(= (:frame-id %) frame-id)))
|
||||||
|
|
||||||
moving-frames
|
moving-frames
|
||||||
(->> ids
|
(filter #(cph/frame-shape? (lookup %)) ids)
|
||||||
(filter #(cph/frame-shape? objects %)))
|
|
||||||
|
|
||||||
changes (-> (pcb/empty-changes it page-id)
|
changes
|
||||||
|
(-> (pcb/empty-changes it page-id)
|
||||||
(pcb/with-objects objects)
|
(pcb/with-objects objects)
|
||||||
(pcb/update-shapes moving-frames (fn [shape] (assoc shape :hide-in-viewer true)))
|
(pcb/update-shapes moving-frames (fn [shape] (assoc shape :hide-in-viewer true)))
|
||||||
(pcb/change-parent frame-id moving-shapes))]
|
(pcb/change-parent frame-id moving-shapes))]
|
||||||
|
|
|
@ -277,7 +277,7 @@
|
||||||
[:& outline/shape-outlines
|
[:& outline/shape-outlines
|
||||||
{:objects base-objects
|
{:objects base-objects
|
||||||
:hover #{(->> @hover-ids
|
:hover #{(->> @hover-ids
|
||||||
(filter #(cph/frame-shape? base-objects %))
|
(filter #(cph/frame-shape? (get base-objects %)))
|
||||||
(remove selected)
|
(remove selected)
|
||||||
(first))}
|
(first))}
|
||||||
:zoom zoom}])
|
:zoom zoom}])
|
||||||
|
|
|
@ -188,11 +188,12 @@
|
||||||
|
|
||||||
grouped? (fn [id] (contains? #{:group :bool} (get-in objects [id :type])))
|
grouped? (fn [id] (contains? #{:group :bool} (get-in objects [id :type])))
|
||||||
|
|
||||||
|
|
||||||
selected-with-parents
|
selected-with-parents
|
||||||
(into #{} (mapcat #(cph/get-parent-ids objects %)) selected)
|
(into #{} (mapcat #(cph/get-parent-ids objects %)) selected)
|
||||||
|
|
||||||
root-frame-with-data? #(and (cph/root-frame? objects %) (d/not-empty? (get-in objects [% :shapes])))
|
root-frame-with-data?
|
||||||
|
#(as-> (get objects %) obj
|
||||||
|
(and (cph/root-frame? obj) (d/not-empty? (:shapes obj))))
|
||||||
|
|
||||||
;; Set with the elements to remove from the hover list
|
;; Set with the elements to remove from the hover list
|
||||||
remove-id?
|
remove-id?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue