mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -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))
|
||||
(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)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
@ -165,11 +165,12 @@
|
|||
parent-id (:parent-id (first selected-shapes))
|
||||
shapes-ids (:shapes (first selected-shapes))
|
||||
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
|
||||
(dwu/start-undo-transaction undo-id)
|
||||
(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
|
||||
:opacity 1})
|
||||
(create-layout-from-id [new-shape-id] type)
|
||||
|
|
|
@ -359,6 +359,8 @@
|
|||
([id]
|
||||
(create-artboard-from-selection id nil))
|
||||
([id parent-id]
|
||||
(create-artboard-from-selection id parent-id nil))
|
||||
([id parent-id index]
|
||||
(ptk/reify ::create-artboard-from-selection
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
|
@ -367,11 +369,8 @@
|
|||
selected (wsh/lookup-selected state)
|
||||
selected (cph/clean-loops objects selected)
|
||||
selected-objs (map #(get objects %) selected)
|
||||
new-index (->> selected
|
||||
(cph/order-by-indexed-shapes objects)
|
||||
first
|
||||
(cph/get-position-on-parent objects)
|
||||
inc)]
|
||||
new-index (or index
|
||||
(cph/get-index-replacement selected objects))]
|
||||
(when (d/not-empty? selected)
|
||||
(let [srect (gsh/selection-rect selected-objs)
|
||||
frame-id (get-in objects [(first selected) :frame-id])
|
||||
|
|
Loading…
Add table
Reference in a new issue