From 14931c1bac634a091157ceceb578bfdb4e530f69 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Tue, 28 Jul 2026 13:25:08 +0200 Subject: [PATCH] :tada: Improve reset to default flow --- frontend/src/app/main/ui/shortcuts.cljs | 26 +++++++++++++++++++++++-- frontend/translations/en.po | 4 ++++ frontend/translations/es.po | 4 ++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/shortcuts.cljs b/frontend/src/app/main/ui/shortcuts.cljs index 2a27c2742b..bc9753305e 100644 --- a/frontend/src/app/main/ui/shortcuts.cljs +++ b/frontend/src/app/main/ui/shortcuts.cljs @@ -371,12 +371,15 @@ conflict* (mf/use-state nil) conflict (deref conflict*) + reset-notification* (mf/use-state nil) + clean-editing-state (fn [] (reset! is-editing* false) (reset! display-parts* nil) (reset! recorded-command* nil) - (reset! conflict* nil)) + (reset! conflict* nil) + (reset! reset-notification* nil)) effective-section-key (if (= section-key :basics) :workspace section-key) @@ -385,7 +388,9 @@ (mf/deps effective-section-key command-info) (fn [shortcut-key] (st/emit! (customize/reset-custom-shortcut shortcut-key (:original-command command-info) effective-section-key)) - (clean-editing-state))) + (reset! reset-notification* (:original-command command-info)) + (reset! recorded-command* nil) + (reset! conflict* nil))) start-editing (mf/use-fn @@ -437,6 +442,15 @@ (when is-editing (some-> (mf/ref-val recording-ref) (dom/focus!)))) + (mf/with-effect [display-parts] + (when (some? display-parts) + (reset! reset-notification* nil))) + + (mf/with-effect [@reset-notification*] + (when-let [_ @reset-notification*] + (let [timer (js/setTimeout #(reset! reset-notification* nil) 7000)] + (fn [] (js/clearTimeout timer))))) + (mf/with-effect [is-editing] (when is-editing (letfn [(on-keydown [^js event] @@ -506,6 +520,14 @@ :customized-key customized?)} (:final-key display-parts)]) (when-not (:finalized? display-parts) [:span {:class (stl/css :recording-ellipsis)} "..."])])] + (when-let [default-cmd @reset-notification*] + [:> context-notification* {:level :info :class (stl/css :modal-reset-msg)} + (tr "shortcuts.edit-modal.reset-to-default") + [:> shortcuts-keys* {:content default-cmd + :command (keyword "default") + :is-customized false + :has-conflict? false}]]) + (when recorded-command (if conflict [:> context-notification* {:level :warning :class (stl/css :modal-error-msg)} diff --git a/frontend/translations/en.po b/frontend/translations/en.po index 3799d37643..c5782eea06 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -5710,6 +5710,10 @@ msgstr "Press the key combination" msgid "shortcuts.edit-modal.conflict" msgstr "Combination assigned to \"%s\". Saving will remove it there." +#: src/app/main/ui/shortcuts.cljs +msgid "shortcuts.edit-modal.reset-to-default" +msgstr "Shortcut reset to default:" + #: src/app/main/ui/shortcuts.cljs msgid "shortcuts.edit-modal.success" msgstr "This key combination is available and can be assigned without conflicts." diff --git a/frontend/translations/es.po b/frontend/translations/es.po index 0660023ff4..6543deb807 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -5565,6 +5565,10 @@ msgstr "Pulsa la combinación de teclas deseada" msgid "shortcuts.edit-modal.conflict" msgstr "Combinación usada en \"%s\". Guardar este atajo hará que se elimine allí." +#: src/app/main/ui/shortcuts.cljs +msgid "shortcuts.edit-modal.reset-to-default" +msgstr "Atajo restablecido a su valor predeterminado:" + #: src/app/main/ui/shortcuts.cljs msgid "shortcuts.edit-modal.success" msgstr "Esta combinación de teclas está disponible y puede asignarse sin conflictos."