From e2e8b9040c3cda80d91a97b2f534360a4d7e34c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Tue, 4 Aug 2026 17:23:08 +0200 Subject: [PATCH] :bug: Fix Firefox not inserting emoji from MacOS Character Viewer --- .../ui/workspace/shapes/text/v3_editor.cljs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs index e626fa2b74..107f850cf4 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/v3_editor.cljs @@ -421,9 +421,21 @@ on-blur (mf/use-fn - (fn [^js _event] - (sync-wasm-text-editor-content! {:finalize? true}) - (wasm.api/text-editor-blur))) + (fn [^js event] + ;; The macOS Character Viewer (emoji picker) on Firefox fires a + ;; spurious `blur` when it opens: the surface stays the document's + ;; activeElement and focus only returns AFTER the emoji arrives as an + ;; `insertText` input. Tearing down the WASM editor focus here clears + ;; `has_focus`, and since `_text_editor_insert_text` is gated on it, + ;; the emoji would be silently dropped (nothing gets inserted). + ;; Skip the teardown while the surface is still the active element; a + ;; genuine blur (focus moved elsewhere) and the explicit unmount + ;; finalize (called with no event) still run. + (when-not (and (some? event) + (= (.-activeElement js/document) + (mf/ref-val contenteditable-ref))) + (sync-wasm-text-editor-content! {:finalize? true}) + (wasm.api/text-editor-blur)))) style #js {:pointerEvents "all" "--editor-container-width" (dm/str width "px")