🐛 Undo text edits from the Edit menu while editing

Edit > Undo and Redo emit the same events as the shortcuts, but the menu
takes the focus. The blurred WASM editor then ignored the restore, so the
menu did nothing while the text edition stayed open.

Focus the editor again before restoring its history.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
alonso.torres 2026-11-03 17:37:37 +01:00
parent 87a21f8a2f
commit 3ddc5ea688

View File

@ -933,14 +933,17 @@
;; The workspace leaves undo to the active editor. Handle the same events
;; for keyboard shortcuts, native history input and workspace menu actions.
;; A menu takes the focus and blurs the WASM editor, which then ignores the
;; restore: take the focus back first, as the edition is still open.
(mf/use-effect
(mf/deps)
(mf/deps focus-editor!)
(fn []
(let [subscription
(->> st/stream
(rx/filter #(or (ptk/type? ::dwu/undo %) (ptk/type? ::dwu/redo %)))
(rx/subs! (fn [event]
(when-not (mf/ref-val composing-ref)
(focus-editor!)
(st/emit! (dwt/v3-restore-history
(if (ptk/type? ::dwu/undo event) :undo :redo)))
(reset-input-node (mf/ref-val contenteditable-ref))