mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -05:00
🐛 Fix index on layout created over group
This commit is contained in:
parent
6a257503ae
commit
40195a4f52
3 changed files with 17 additions and 7 deletions
|
@ -353,6 +353,16 @@
|
||||||
(filter (comp (into #{} ids) second))
|
(filter (comp (into #{} ids) second))
|
||||||
(map second)))
|
(map second)))
|
||||||
|
|
||||||
|
(defn get-index-replacement
|
||||||
|
"Given a collection of shapes, calculate their positions
|
||||||
|
in the parent, find first index and return next one"
|
||||||
|
[shapes objects]
|
||||||
|
(->> shapes
|
||||||
|
(order-by-indexed-shapes objects)
|
||||||
|
first
|
||||||
|
(get-position-on-parent objects)
|
||||||
|
inc))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; SHAPES ORGANIZATION (PATH MANAGEMENT)
|
;; SHAPES ORGANIZATION (PATH MANAGEMENT)
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -165,11 +165,12 @@
|
||||||
parent-id (:parent-id (first selected-shapes))
|
parent-id (:parent-id (first selected-shapes))
|
||||||
shapes-ids (:shapes (first selected-shapes))
|
shapes-ids (:shapes (first selected-shapes))
|
||||||
ordered-ids (into (d/ordered-set) shapes-ids)
|
ordered-ids (into (d/ordered-set) shapes-ids)
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)
|
||||||
|
group-index (cph/get-index-replacement selected objects)]
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dwse/select-shapes ordered-ids)
|
(dwse/select-shapes ordered-ids)
|
||||||
(dws/create-artboard-from-selection new-shape-id parent-id)
|
(dws/create-artboard-from-selection new-shape-id parent-id group-index)
|
||||||
(cl/remove-all-fills [new-shape-id] {:color clr/black
|
(cl/remove-all-fills [new-shape-id] {:color clr/black
|
||||||
:opacity 1})
|
:opacity 1})
|
||||||
(create-layout-from-id [new-shape-id] type)
|
(create-layout-from-id [new-shape-id] type)
|
||||||
|
|
|
@ -359,6 +359,8 @@
|
||||||
([id]
|
([id]
|
||||||
(create-artboard-from-selection id nil))
|
(create-artboard-from-selection id nil))
|
||||||
([id parent-id]
|
([id parent-id]
|
||||||
|
(create-artboard-from-selection id parent-id nil))
|
||||||
|
([id parent-id index]
|
||||||
(ptk/reify ::create-artboard-from-selection
|
(ptk/reify ::create-artboard-from-selection
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
@ -367,11 +369,8 @@
|
||||||
selected (wsh/lookup-selected state)
|
selected (wsh/lookup-selected state)
|
||||||
selected (cph/clean-loops objects selected)
|
selected (cph/clean-loops objects selected)
|
||||||
selected-objs (map #(get objects %) selected)
|
selected-objs (map #(get objects %) selected)
|
||||||
new-index (->> selected
|
new-index (or index
|
||||||
(cph/order-by-indexed-shapes objects)
|
(cph/get-index-replacement selected objects))]
|
||||||
first
|
|
||||||
(cph/get-position-on-parent objects)
|
|
||||||
inc)]
|
|
||||||
(when (d/not-empty? selected)
|
(when (d/not-empty? selected)
|
||||||
(let [srect (gsh/selection-rect selected-objs)
|
(let [srect (gsh/selection-rect selected-objs)
|
||||||
frame-id (get-in objects [(first selected) :frame-id])
|
frame-id (get-in objects [(first selected) :frame-id])
|
||||||
|
|
Loading…
Add table
Reference in a new issue