From 0f60f115f5f3c5b017fcc69fa927e8cbc8b8a403 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 14 Jul 2023 14:10:26 +0200 Subject: [PATCH] :bug: Fix focus list for texts --- .../app/main/ui/workspace/shapes/text/editor.cljs | 12 +++++++----- frontend/src/app/util/text_editor.cljs | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs index 64805ef19..52afa3514 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs @@ -131,11 +131,13 @@ (mf/use-callback (mf/deps shape state) (fn [event] - (dom/stop-propagation event) - (dom/prevent-default event) - (st/emit! ::dwt/finalize-editor-state) - (st/emit! (dwt/initialize-editor-state shape default-decorator)) - (reset! blurred true))) + (let [is-empty? (ted/is-current-empty state)] + (dom/stop-propagation event) + (dom/prevent-default event) + (when (not is-empty?) + (st/emit! ::dwt/finalize-editor-state) + (st/emit! (dwt/initialize-editor-state shape default-decorator))) + (reset! blurred true)))) on-focus (mf/use-callback diff --git a/frontend/src/app/util/text_editor.cljs b/frontend/src/app/util/text_editor.cljs index 42708f63f..a6cedcce8 100644 --- a/frontend/src/app/util/text_editor.cljs +++ b/frontend/src/app/util/text_editor.cljs @@ -73,6 +73,10 @@ (let [block (impl/getCurrentBlock state)] (get-editor-block-data block))) +(defn is-current-empty + [state] + (impl/isCurrentEmpty state)) + (defn get-editor-current-inline-styles [state] (if (impl/isCurrentEmpty state)