mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 01:01:37 +02:00
🐛 Fix wrong behavior on shape/canvas hide/show options.
This commit is contained in:
parent
8f77a59a97
commit
6988f0a35e
2 changed files with 33 additions and 15 deletions
|
@ -1757,6 +1757,7 @@
|
|||
[id]
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(impl-update-shape-hidden state id true))))
|
||||
|
@ -1764,24 +1765,41 @@
|
|||
(defn show-shape
|
||||
[id]
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
(ptk/reify ::show-shape
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(impl-update-shape-hidden state id false))))
|
||||
|
||||
(defn hide-canvas
|
||||
[id]
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [hide #(impl-update-shape-hidden %1 %2 true)
|
||||
ids (->> (vals (get-in state [:workspace-data :shapes-by-id]))
|
||||
(filter #(= (:canvas %) id))
|
||||
(map :id))]
|
||||
(reduce hide state (cons id ids))))))
|
||||
|
||||
(defn show-canvas
|
||||
[id]
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [show #(impl-update-shape-hidden %1 %2 false)
|
||||
ids (->> (vals (get-in state [:workspace-data :shapes-by-id]))
|
||||
(filter #(= (:canvas %) id))
|
||||
(map :id))]
|
||||
(reduce show state (cons id ids))))))
|
||||
|
||||
(defn- impl-update-shape-hidden
|
||||
[state id hidden?]
|
||||
(let [type (get-in state [:workspace-data :shapes-by-id id :type])
|
||||
state (update-in state [:workspace-data :shapes-by-id id] assoc :hidden hidden?)]
|
||||
(cond-> state
|
||||
(= type :canvas)
|
||||
(update-in [:workspace-data :shapes-by-id]
|
||||
(fn [shapes]
|
||||
(reduce-kv (fn [shapes key {:keys [canvas] :as val}]
|
||||
(cond-> shapes
|
||||
(= id canvas) (update key assoc :hidden hidden?)))
|
||||
shapes
|
||||
shapes))))))
|
||||
(assoc-in state [:workspace-data :shapes-by-id id :hidden] hidden?))
|
||||
|
||||
;; --- Shape Blocking
|
||||
|
||||
|
|
|
@ -173,8 +173,8 @@
|
|||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(if (:hidden canvas)
|
||||
(st/emit! (dw/show-shape (:id canvas)))
|
||||
(st/emit! (dw/hide-shape (:id canvas)))))
|
||||
(st/emit! (dw/show-canvas (:id canvas)))
|
||||
(st/emit! (dw/hide-canvas (:id canvas)))))
|
||||
|
||||
select-shape
|
||||
(fn [event]
|
||||
|
@ -274,7 +274,7 @@
|
|||
data (mf/deref refs/workspace-data)
|
||||
|
||||
shapes-map (:shapes-by-id data)
|
||||
strip #(select-keys % [:id :canvas :name :type])
|
||||
strip #(select-keys % [:id :canvas :name :type :hidden :blocked])
|
||||
|
||||
canvas (->> (:canvas data)
|
||||
(map #(get shapes-map %))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue