mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
🐛 Fix swap panel keeps open after undo
This commit is contained in:
parent
23527b1d19
commit
3983cb161e
5 changed files with 41 additions and 37 deletions
|
@ -27,6 +27,7 @@
|
|||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.collapse :as dwc]
|
||||
[app.main.data.workspace.libraries-helpers :as dwlh]
|
||||
[app.main.data.workspace.specialized-panel :as-alias dwsp]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.zoom :as dwz]
|
||||
|
@ -124,14 +125,15 @@
|
|||
(update [_ state]
|
||||
(-> state
|
||||
(update-in [:workspace-local :selected] d/toggle-selection id toggle?)
|
||||
(assoc-in [:workspace-local :last-selected] id)
|
||||
(dissoc :specialized-panel)))
|
||||
(assoc-in [:workspace-local :last-selected] id)))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)]
|
||||
(rx/of (dwc/expand-all-parents [id] objects)))))))
|
||||
(rx/of
|
||||
(dwc/expand-all-parents [id] objects)
|
||||
::dwsp/interrupt))))))
|
||||
|
||||
(defn select-prev-shape
|
||||
([]
|
||||
|
@ -186,12 +188,14 @@
|
|||
[id]
|
||||
(dm/assert! (uuid? id))
|
||||
(ptk/reify ::deselect-shape
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of ::dwsp/interrupt))
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
(update-in [:workspace-local :selected] disj id)
|
||||
(update :workspace-local dissoc :last-selected)
|
||||
(dissoc :specialized-panel)))))
|
||||
(update :workspace-local dissoc :last-selected)))))
|
||||
|
||||
(defn shift-select-shapes
|
||||
([id]
|
||||
|
@ -199,6 +203,9 @@
|
|||
|
||||
([id objects]
|
||||
(ptk/reify ::shift-select-shapes
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of ::dwsp/interrupt))
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [objects (or objects (wsh/lookup-page-objects state))
|
||||
|
@ -208,9 +215,8 @@
|
|||
(conj id))]
|
||||
(-> state
|
||||
(assoc-in [:workspace-local :selected]
|
||||
(set/union selection append-to-selection))
|
||||
(update :workspace-local assoc :last-selected id)
|
||||
(dissoc :specialized-panel)))))))
|
||||
(set/union selection append-to-selection))
|
||||
(update :workspace-local assoc :last-selected id)))))))
|
||||
|
||||
(defn select-shapes
|
||||
[ids]
|
||||
|
@ -227,14 +233,14 @@
|
|||
ids (if (d/not-empty? focus)
|
||||
(cpf/filter-not-focus objects focus ids)
|
||||
ids)]
|
||||
(-> state
|
||||
(assoc-in [:workspace-local :selected] ids)
|
||||
(dissoc :specialized-panel))))
|
||||
(assoc-in state [:workspace-local :selected] ids)))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [objects (wsh/lookup-page-objects state)]
|
||||
(rx/of (dwc/expand-all-parents ids objects))))))
|
||||
(rx/of
|
||||
(dwc/expand-all-parents ids objects)
|
||||
::dwsp/interrupt)))))
|
||||
|
||||
(defn select-all
|
||||
[]
|
||||
|
@ -273,6 +279,9 @@
|
|||
|
||||
([check-modal]
|
||||
(ptk/reify ::deselect-all
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of ::dwsp/interrupt))
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
||||
|
@ -283,9 +292,7 @@
|
|||
(update :workspace-local
|
||||
#(-> %
|
||||
(assoc :selected (d/ordered-set))
|
||||
(dissoc :selected-frame)))
|
||||
:allways
|
||||
(dissoc :specialized-panel))))))
|
||||
(dissoc :selected-frame))))))))
|
||||
|
||||
;; --- Select Shapes (By selrect)
|
||||
|
||||
|
|
|
@ -7,38 +7,35 @@
|
|||
(ns app.main.data.workspace.specialized-panel
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.main.data.workspace.common :as-alias dwc]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(defn interrupt? [e] (= e :interrupt))
|
||||
(defn interrupt? [e] (or (= e :interrupt) (= e ::interrupt)))
|
||||
|
||||
(def clear-specialized-panel
|
||||
(defn clear-specialized-panel
|
||||
[]
|
||||
(ptk/reify ::clear-specialized-panel
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(dissoc state :specialized-panel))))
|
||||
|
||||
|
||||
(defn open-specialized-panel
|
||||
([type]
|
||||
(ptk/reify ::open-specialized-panel-1
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
[type]
|
||||
(ptk/reify ::open-specialized-panel
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected-ids (wsh/lookup-selected state)
|
||||
selected-shapes (map (d/getf objects) selected-ids)]
|
||||
|
||||
(rx/of (open-specialized-panel type selected-shapes))))))
|
||||
|
||||
([type shapes]
|
||||
(ptk/reify ::open-specialized-panel-2
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc state :specialized-panel {:type type :shapes shapes}))
|
||||
(assoc state :specialized-panel {:type type :shapes selected-shapes})))
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(->> stream
|
||||
(rx/filter interrupt?)
|
||||
(->> (rx/merge
|
||||
(rx/filter interrupt? stream)
|
||||
(rx/filter (ptk/type? ::dwc/undo) stream))
|
||||
(rx/take 1)
|
||||
(rx/map (constantly clear-specialized-panel)))))))
|
||||
(rx/map clear-specialized-panel)))))
|
||||
|
|
|
@ -840,7 +840,7 @@
|
|||
;; Remove layout-item properties when moving a shape outside a layout
|
||||
(cond-> (not (ctl/any-layout? objects frame-id))
|
||||
(pcb/update-shapes moving-shapes-ids ctl/remove-layout-item-data))
|
||||
;; Remove componnet-root property when moving a shape inside a component
|
||||
;; Remove component-root property when moving a shape inside a component
|
||||
(cond-> (ctn/get-instance-root objects frame)
|
||||
(pcb/update-shapes moving-shapes-ids #(dissoc % :component-root)))
|
||||
(pcb/update-shapes moving-shapes-ids #(cond-> % (cfh/frame-shape? %) (assoc :hide-in-viewer true)))
|
||||
|
|
|
@ -442,12 +442,12 @@
|
|||
|
||||
on-component-back
|
||||
(mf/use-fn
|
||||
#(st/emit! :interrupt))
|
||||
#(st/emit! ::dwsp/interrupt))
|
||||
|
||||
open-component-panel
|
||||
(mf/use-fn
|
||||
(mf/deps can-swap? shapes)
|
||||
#(when can-swap? (st/emit! (dwsp/open-specialized-panel :component-swap shapes))))
|
||||
#(when can-swap? (st/emit! (dwsp/open-specialized-panel :component-swap))))
|
||||
|
||||
menu-entries (cmm/generate-components-menu-entries shapes components-v2)
|
||||
show-menu? (seq menu-entries)]
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.data.workspace.media :as dwm]
|
||||
[app.main.data.workspace.path :as dwdp]
|
||||
[app.main.data.workspace.specialized-panel :as dwsp]
|
||||
[app.main.data.workspace.specialized-panel :as-alias dwsp]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.streams :as ms]
|
||||
|
@ -86,7 +86,7 @@
|
|||
left-click?
|
||||
(do
|
||||
(st/emit! (ms/->MouseEvent :down ctrl? shift? alt? meta?)
|
||||
dwsp/clear-specialized-panel)
|
||||
::dwsp/interrupt)
|
||||
|
||||
(when (and (not= edition id) (or text-editing? grid-editing?))
|
||||
(st/emit! dw/clear-edition-mode))
|
||||
|
|
Loading…
Add table
Reference in a new issue