🐛 Fix glitch when using drawing tool in toolbar (#10447)

This commit is contained in:
Luis de Dios 2026-07-08 09:55:50 +02:00 committed by GitHub
parent f51db39b8d
commit 4eaefec43e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 22 deletions

View File

@ -47,16 +47,6 @@
(when (= tool :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
;; own interrupt cycle.
(when (= tool :comments)
@ -68,7 +58,7 @@
(->> stream
(rx/filter dwc/interrupt?)
(rx/take 1)
(rx/map common/clear-drawing)
(rx/map #(common/clear-drawing {:preserve-tool? true}))
(rx/take-until stopper))))))))
;; NOTE/TODO: when an exception is raised in some point of drawing the

View File

@ -18,11 +18,14 @@
[potok.v2.core :as ptk]))
(defn clear-drawing
[]
(ptk/reify ::clear-drawing
ptk/UpdateEvent
(update [_ state]
(dissoc state :workspace-drawing))))
([] (clear-drawing nil))
([{:keys [preserve-tool?]}]
(ptk/reify ::clear-drawing
ptk/UpdateEvent
(update [_ state]
(if preserve-tool?
(update state :workspace-drawing dissoc :object :lock)
(dissoc state :workspace-drawing))))))
(defn handle-finish-drawing
[]
@ -95,6 +98,5 @@
(rx/empty)))))
;; 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)))))))

View File

@ -13,7 +13,9 @@
[beicon.v2.core :as rx]
[potok.v2.core :as ptk]))
(defn interrupt? [e] (= e :interrupt))
(defn interrupt?
[e]
(= e :interrupt))
(declare clear-edition-mode)
@ -51,7 +53,7 @@
(update [_ state]
(-> state
(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-wasm-editor-styles)))

View File

@ -18,6 +18,7 @@
[app.main.data.workspace.colors :as mdc]
[app.main.data.workspace.comments :as dwcm]
[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.libraries :as dwl]
[app.main.data.workspace.shape-layout :as dwsl]
@ -149,7 +150,7 @@
:escape {:tooltip (ds/esc)
:command "escape"
: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]
:fn #(st/emit! (dw/open-layers-search :find))}

View File

@ -13,6 +13,7 @@
[app.main.data.modal :as modal]
[app.main.data.workspace :as dw]
[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.media :as dwm]
[app.main.data.workspace.shortcuts :as sc]
@ -313,7 +314,9 @@
on-interrupt
(mf/use-fn
(fn []
(st/emit! :interrupt (dw/clear-edition-mode))))
(st/emit! :interrupt
(dw/clear-edition-mode)
(dwdc/clear-drawing))))
on-select-tool
(mf/use-fn