mirror of
https://github.com/penpot/penpot.git
synced 2026-08-04 20:09:05 +00:00
🐛 Fix glitch when using drawing tool in toolbar (#10447)
This commit is contained in:
parent
f51db39b8d
commit
4eaefec43e
@ -47,16 +47,6 @@
|
|||||||
(when (= tool :path)
|
(when (= tool :path)
|
||||||
(rx/of (start-drawing :path)))
|
(rx/of (start-drawing :path)))
|
||||||
|
|
||||||
(when (= tool :curve)
|
|
||||||
(let [stopper (rx/filter dwc/interrupt? stream)]
|
|
||||||
(->> stream
|
|
||||||
(rx/filter (ptk/type? ::common/handle-finish-drawing))
|
|
||||||
(rx/map (constantly tool))
|
|
||||||
(rx/take 1)
|
|
||||||
(rx/observe-on :async)
|
|
||||||
(rx/map select-for-drawing)
|
|
||||||
(rx/take-until stopper))))
|
|
||||||
|
|
||||||
;; NOTE: comments are a special case and they manage they
|
;; NOTE: comments are a special case and they manage they
|
||||||
;; own interrupt cycle.
|
;; own interrupt cycle.
|
||||||
(when (= tool :comments)
|
(when (= tool :comments)
|
||||||
@ -68,7 +58,7 @@
|
|||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter dwc/interrupt?)
|
(rx/filter dwc/interrupt?)
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/map common/clear-drawing)
|
(rx/map #(common/clear-drawing {:preserve-tool? true}))
|
||||||
(rx/take-until stopper))))))))
|
(rx/take-until stopper))))))))
|
||||||
|
|
||||||
;; NOTE/TODO: when an exception is raised in some point of drawing the
|
;; NOTE/TODO: when an exception is raised in some point of drawing the
|
||||||
|
|||||||
@ -18,11 +18,14 @@
|
|||||||
[potok.v2.core :as ptk]))
|
[potok.v2.core :as ptk]))
|
||||||
|
|
||||||
(defn clear-drawing
|
(defn clear-drawing
|
||||||
[]
|
([] (clear-drawing nil))
|
||||||
(ptk/reify ::clear-drawing
|
([{:keys [preserve-tool?]}]
|
||||||
ptk/UpdateEvent
|
(ptk/reify ::clear-drawing
|
||||||
(update [_ state]
|
ptk/UpdateEvent
|
||||||
(dissoc state :workspace-drawing))))
|
(update [_ state]
|
||||||
|
(if preserve-tool?
|
||||||
|
(update state :workspace-drawing dissoc :object :lock)
|
||||||
|
(dissoc state :workspace-drawing))))))
|
||||||
|
|
||||||
(defn handle-finish-drawing
|
(defn handle-finish-drawing
|
||||||
[]
|
[]
|
||||||
@ -95,6 +98,5 @@
|
|||||||
(rx/empty)))))
|
(rx/empty)))))
|
||||||
|
|
||||||
;; Delay so the mouse event can read the drawing state
|
;; Delay so the mouse event can read the drawing state
|
||||||
(->> (rx/of (clear-drawing))
|
(->> (rx/of (clear-drawing {:preserve-tool? (= tool :curve)}))
|
||||||
(rx/delay 0)))))))
|
(rx/delay 0)))))))
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,9 @@
|
|||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[potok.v2.core :as ptk]))
|
[potok.v2.core :as ptk]))
|
||||||
|
|
||||||
(defn interrupt? [e] (= e :interrupt))
|
(defn interrupt?
|
||||||
|
[e]
|
||||||
|
(= e :interrupt))
|
||||||
|
|
||||||
(declare clear-edition-mode)
|
(declare clear-edition-mode)
|
||||||
|
|
||||||
@ -51,7 +53,7 @@
|
|||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :workspace-local dissoc :edition :edit-path)
|
(update :workspace-local dissoc :edition :edit-path)
|
||||||
(update :workspace-drawing dissoc :tool :object :lock)
|
(update :workspace-drawing dissoc :object :lock)
|
||||||
(dissoc :workspace-grid-edition)
|
(dissoc :workspace-grid-edition)
|
||||||
(dissoc :workspace-wasm-editor-styles)))
|
(dissoc :workspace-wasm-editor-styles)))
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
[app.main.data.workspace.colors :as mdc]
|
[app.main.data.workspace.colors :as mdc]
|
||||||
[app.main.data.workspace.comments :as dwcm]
|
[app.main.data.workspace.comments :as dwcm]
|
||||||
[app.main.data.workspace.drawing :as dwd]
|
[app.main.data.workspace.drawing :as dwd]
|
||||||
|
[app.main.data.workspace.drawing.common :as dwdc]
|
||||||
[app.main.data.workspace.layers :as dwly]
|
[app.main.data.workspace.layers :as dwly]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.shape-layout :as dwsl]
|
[app.main.data.workspace.shape-layout :as dwsl]
|
||||||
@ -149,7 +150,7 @@
|
|||||||
:escape {:tooltip (ds/esc)
|
:escape {:tooltip (ds/esc)
|
||||||
:command "escape"
|
:command "escape"
|
||||||
:subsections [:edit]
|
:subsections [:edit]
|
||||||
:fn #(st/emit! :interrupt (dw/deselect-all true))}
|
:fn #(st/emit! :interrupt (dwdc/clear-drawing) (dw/deselect-all true))}
|
||||||
|
|
||||||
:find {:tooltip (ds/meta "F") :command (ds/c-mod "f") :subsections [:edit]
|
:find {:tooltip (ds/meta "F") :command (ds/c-mod "f") :subsections [:edit]
|
||||||
:fn #(st/emit! (dw/open-layers-search :find))}
|
:fn #(st/emit! (dw/open-layers-search :find))}
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
|
[app.main.data.workspace.drawing.common :as dwdc]
|
||||||
[app.main.data.workspace.mcp :as mcp]
|
[app.main.data.workspace.mcp :as mcp]
|
||||||
[app.main.data.workspace.media :as dwm]
|
[app.main.data.workspace.media :as dwm]
|
||||||
[app.main.data.workspace.shortcuts :as sc]
|
[app.main.data.workspace.shortcuts :as sc]
|
||||||
@ -313,7 +314,9 @@
|
|||||||
on-interrupt
|
on-interrupt
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! :interrupt (dw/clear-edition-mode))))
|
(st/emit! :interrupt
|
||||||
|
(dw/clear-edition-mode)
|
||||||
|
(dwdc/clear-drawing))))
|
||||||
|
|
||||||
on-select-tool
|
on-select-tool
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user