mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 17:18:21 -05:00
Merge pull request #4230 from penpot/azazeln28-component-layers-incorrectly-relocated
🐛 Component layers are incorrectly relocated on drag'n'drop
This commit is contained in:
commit
e25c1e987c
1 changed files with 20 additions and 17 deletions
|
@ -262,29 +262,32 @@
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps id index objects expanded? selected)
|
(mf/deps id index objects expanded? selected)
|
||||||
(fn [side _data]
|
(fn [side _data]
|
||||||
(let [shape (get objects id)
|
(let [single? (= (count selected) 1)
|
||||||
|
same? (and single? (= (first selected) id))]
|
||||||
|
(when-not same?
|
||||||
|
(let [shape (get objects id)
|
||||||
|
|
||||||
parent-id
|
parent-id
|
||||||
(cond
|
(cond
|
||||||
(= side :center)
|
(= side :center)
|
||||||
id
|
id
|
||||||
|
|
||||||
(and expanded? (= side :bot) (d/not-empty? (:shapes shape)))
|
(and expanded? (= side :bot) (d/not-empty? (:shapes shape)))
|
||||||
id
|
id
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(cfh/get-parent-id objects id))
|
(cfh/get-parent-id objects id))
|
||||||
|
|
||||||
[parent-id _] (ctn/find-valid-parent-and-frame-ids parent-id objects (map #(get objects %) selected))
|
[parent-id _] (ctn/find-valid-parent-and-frame-ids parent-id objects (map #(get objects %) selected))
|
||||||
|
|
||||||
parent (get objects parent-id)
|
parent (get objects parent-id)
|
||||||
|
|
||||||
to-index (cond
|
to-index (cond
|
||||||
(= side :center) 0
|
(= side :center) 0
|
||||||
(and expanded? (= side :bot) (d/not-empty? (:shapes shape))) (count (:shapes parent))
|
(and expanded? (= side :bot) (d/not-empty? (:shapes shape))) (count (:shapes parent))
|
||||||
(= side :top) (inc index)
|
(= side :top) (inc index)
|
||||||
:else index)]
|
:else index)]
|
||||||
(st/emit! (dw/relocate-selected-shapes parent-id to-index)))))
|
(st/emit! (dw/relocate-selected-shapes parent-id to-index)))))))
|
||||||
|
|
||||||
on-hold
|
on-hold
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
Loading…
Add table
Reference in a new issue