0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

🐛 Fixed some issues when shift-selecting on sidebars

This commit is contained in:
alonso.torres 2021-03-26 10:41:27 +01:00
parent 68eadcb24f
commit 20e4562c09
5 changed files with 25 additions and 15 deletions

View file

@ -187,16 +187,18 @@
(defn clean-loops
"Clean a list of ids from circular references."
[objects ids]
(loop [ids ids
id (first ids)
others (rest ids)]
(if-not id
ids
(recur (cond-> ids
(some #(contains? ids %) (get-parents id objects))
(disj id))
(first others)
(rest others)))))
(let [parent-selected?
(fn [id]
(let [parents (get-parents id objects)]
(some ids parents)))
add-element
(fn [result id]
(cond-> result
(not (parent-selected? id))
(conj id)))]
(reduce add-element (d/ordered-set) ids)))
(defn calculate-invalid-targets
[shape-id objects]

View file

@ -1352,7 +1352,8 @@
ptk/WatchEvent
(watch [_ state stream]
(let [objects (dwc/lookup-page-objects state)
selected (get-in state [:workspace-local :selected])
selected (->> (get-in state [:workspace-local :selected])
(cp/clean-loops objects))
pdata (reduce (partial collect-object-ids objects) {} selected)
initial {:type :copied-shapes
:file-id (:current-file-id state)

View file

@ -20,8 +20,8 @@
(mf/defc outline
{::mf/wrap-props false}
[props]
(let [zoom (mf/deref refs/selected-zoom)
shape (unchecked-get props "shape")
(let [shape (unchecked-get props "shape")
zoom (unchecked-get props "zoom")
color (unchecked-get props "color")
transform (gsh/transform-matrix shape)
path? (= :path (:type shape))

View file

@ -202,7 +202,8 @@
:selected selected
:hover (when (not= :frame (:type @hover))
#{(or @frame-hover (:id @hover))})
:edition edition}])
:edition edition
:zoom zoom}])
(when show-selection-handlers?
[:& selection/selection-handlers

View file

@ -296,7 +296,13 @@
(mf/defc multiple-selection-handlers
[{:keys [shapes selected zoom color show-distances disable-handlers on-move-selected] :as props}]
(let [shape (geom/setup {:type :rect} (geom/selection-rect (->> shapes (map geom/transform-shape))))
(let [shape (mf/use-memo
(mf/deps shapes)
#(->> shapes
(map geom/transform-shape)
(geom/selection-rect)
(geom/setup {:type :rect})))
shape-center (geom/center-shape shape)
hover-id (-> (mf/deref refs/current-hover) first)