mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 04:49:03 -05:00
🐛 Fixed some issues when shift-selecting on sidebars
This commit is contained in:
parent
68eadcb24f
commit
20e4562c09
5 changed files with 25 additions and 15 deletions
|
@ -187,16 +187,18 @@
|
||||||
(defn clean-loops
|
(defn clean-loops
|
||||||
"Clean a list of ids from circular references."
|
"Clean a list of ids from circular references."
|
||||||
[objects ids]
|
[objects ids]
|
||||||
(loop [ids ids
|
(let [parent-selected?
|
||||||
id (first ids)
|
(fn [id]
|
||||||
others (rest ids)]
|
(let [parents (get-parents id objects)]
|
||||||
(if-not id
|
(some ids parents)))
|
||||||
ids
|
|
||||||
(recur (cond-> ids
|
add-element
|
||||||
(some #(contains? ids %) (get-parents id objects))
|
(fn [result id]
|
||||||
(disj id))
|
(cond-> result
|
||||||
(first others)
|
(not (parent-selected? id))
|
||||||
(rest others)))))
|
(conj id)))]
|
||||||
|
|
||||||
|
(reduce add-element (d/ordered-set) ids)))
|
||||||
|
|
||||||
(defn calculate-invalid-targets
|
(defn calculate-invalid-targets
|
||||||
[shape-id objects]
|
[shape-id objects]
|
||||||
|
|
|
@ -1352,7 +1352,8 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [objects (dwc/lookup-page-objects state)
|
(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)
|
pdata (reduce (partial collect-object-ids objects) {} selected)
|
||||||
initial {:type :copied-shapes
|
initial {:type :copied-shapes
|
||||||
:file-id (:current-file-id state)
|
:file-id (:current-file-id state)
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
(mf/defc outline
|
(mf/defc outline
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [zoom (mf/deref refs/selected-zoom)
|
(let [shape (unchecked-get props "shape")
|
||||||
shape (unchecked-get props "shape")
|
zoom (unchecked-get props "zoom")
|
||||||
color (unchecked-get props "color")
|
color (unchecked-get props "color")
|
||||||
transform (gsh/transform-matrix shape)
|
transform (gsh/transform-matrix shape)
|
||||||
path? (= :path (:type shape))
|
path? (= :path (:type shape))
|
||||||
|
|
|
@ -202,7 +202,8 @@
|
||||||
:selected selected
|
:selected selected
|
||||||
:hover (when (not= :frame (:type @hover))
|
:hover (when (not= :frame (:type @hover))
|
||||||
#{(or @frame-hover (:id @hover))})
|
#{(or @frame-hover (:id @hover))})
|
||||||
:edition edition}])
|
:edition edition
|
||||||
|
:zoom zoom}])
|
||||||
|
|
||||||
(when show-selection-handlers?
|
(when show-selection-handlers?
|
||||||
[:& selection/selection-handlers
|
[:& selection/selection-handlers
|
||||||
|
|
|
@ -296,7 +296,13 @@
|
||||||
|
|
||||||
(mf/defc multiple-selection-handlers
|
(mf/defc multiple-selection-handlers
|
||||||
[{:keys [shapes selected zoom color show-distances disable-handlers on-move-selected] :as props}]
|
[{: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)
|
shape-center (geom/center-shape shape)
|
||||||
|
|
||||||
hover-id (-> (mf/deref refs/current-hover) first)
|
hover-id (-> (mf/deref refs/current-hover) first)
|
||||||
|
|
Loading…
Add table
Reference in a new issue