From b80456b607a77a0c3006afcfb243c25fd3f1f962 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Thu, 26 Nov 2026 14:19:30 +0100 Subject: [PATCH] :sparkles: Leave the opacity shortcuts without a default key (#13309) * :sparkles: Leave the opacity shortcuts without a default key Number keys set the opacity of the selection and were easy to press by accident, for example after an input lost the focus. The opacity shortcuts stay, with no default key: users who want them assign a key in Settings. The settings rows show the no-key icon for any shortcut without a key, and the reset notice shows it when the default has none. Closes #13303 AI-assisted-by: claude-opus-5-5 * :books: Document the opacity shortcuts without a default key The shortcuts page listed the number keys for the opacity shortcuts. Show one row with no default keys, linked to the customize section, and drop the AZERTY note about those keys. AI-assisted-by: claude-opus-5-5 --- docs/user-guide/first-steps/shortcuts.njk | 51 +------------------ .../app/main/data/workspace/shortcuts.cljs | 33 +++++------- frontend/src/app/main/ui/shortcuts.cljs | 20 +++++--- .../data/workspace_shortcuts_test.cljs | 19 +++++++ 4 files changed, 48 insertions(+), 75 deletions(-) diff --git a/docs/user-guide/first-steps/shortcuts.njk b/docs/user-guide/first-steps/shortcuts.njk index 7dd41ab931..32ef27e862 100644 --- a/docs/user-guide/first-steps/shortcuts.njk +++ b/docs/user-guide/first-steps/shortcuts.njk @@ -37,7 +37,6 @@ desc: Get quickstart tips, shortcuts, and tutorials for Penpot! Learn interface

Keyboard layouts

Letters are recorded by the character they type, so they follow your layout (on AZERTY, the A key records a). With Shift, Alt or another modifier, letter and digit keys record the key itself, not the character the modifier makes (Shift0, not Shift); ⌥M on macOS, not µ).

Punctuation keys (such as -, [, / or ') are recorded by their physical position on the keyboard, so Shift with the + key records Shift+ on a Spanish layout. In browsers that do not expose the keyboard layout, such as Firefox or Safari, Penpot records the character you type instead; the shortcut still works there. Keys typed with AltGr record the character they type (\ on a Spanish layout).

-

One known limitation: number keys set opacity (0–9) only where digits are typed without Shift, so AZERTY layouts need the numeric keypad for them.

Reset to default

When you have custom shortcuts, a Reset all button appears next to the search field. It lists every shortcut that will go back to its default before you confirm.

@@ -399,54 +398,8 @@ desc: Get quickstart tips, shortcuts, and tutorials for Penpot! Learn interface - Set opacity to 10% - 1 - 1 - - - Set opacity to 20% - 2 - 2 - - - Set opacity to 30% - 3 - 3 - - - Set opacity to 40% - 4 - 4 - - - Set opacity to 50% - 5 - 5 - - - Set opacity to 60% - 6 - 6 - - - Set opacity to 70% - 7 - 7 - - - Set opacity to 80% - 8 - 8 - - - Set opacity to 90% - 9 - 9 - - - Set opacity to 100% - 0 - 0 + Set opacity to 10%, 20%… 100% + No default keys. Assign them in Customize shortcuts. Ungroup diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs index 0a81071eb2..ef4f5df093 100644 --- a/frontend/src/app/main/data/workspace/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/shortcuts.cljs @@ -854,64 +854,57 @@ :command (ds/c-mod "alt+enter") :fn #(emit-when-no-readonly (dp/open-preview-selected))}}) +;; Number keys used to set the opacity of the selection, and were easy to +;; press by accident (https://github.com/penpot/penpot/issues/13303). The +;; shortcuts stay, with no default key: users assign one in Settings. (def opacity-shortcuts {:opacity-0 {:label (fn [] (tr "shortcuts.opacity-0")) - :tooltip "0" - :command ["0" "num0"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 0))} :opacity-1 {:label (fn [] (tr "shortcuts.opacity-1")) - :tooltip "1" - :command ["1" "num1"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 1))} :opacity-2 {:label (fn [] (tr "shortcuts.opacity-2")) - :tooltip "2" - :command ["2" "num2"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 2))} :opacity-3 {:label (fn [] (tr "shortcuts.opacity-3")) - :tooltip "3" - :command ["3" "num3"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 3))} :opacity-4 {:label (fn [] (tr "shortcuts.opacity-4")) - :tooltip "4" - :command ["4" "num4"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 4))} :opacity-5 {:label (fn [] (tr "shortcuts.opacity-5")) - :tooltip "5" - :command ["5" "num5"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 5))} :opacity-6 {:label (fn [] (tr "shortcuts.opacity-6")) - :tooltip "6" - :command ["6" "num6"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 6))} :opacity-7 {:label (fn [] (tr "shortcuts.opacity-7")) - :tooltip "7" - :command ["7" "num7"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 7))} :opacity-8 {:label (fn [] (tr "shortcuts.opacity-8")) - :tooltip "8" - :command ["8" "num8"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 8))} :opacity-9 {:label (fn [] (tr "shortcuts.opacity-9")) - :tooltip "9" - :command ["9" "num9"] + :command "" :section [:workspace] :subsections [:modify-layers] :fn #(emit-when-no-readonly (dwly/pressed-opacity 9))}}) diff --git a/frontend/src/app/main/ui/shortcuts.cljs b/frontend/src/app/main/ui/shortcuts.cljs index 64df9a10bf..c95bb51872 100644 --- a/frontend/src/app/main/ui/shortcuts.cljs +++ b/frontend/src/app/main/ui/shortcuts.cljs @@ -719,7 +719,9 @@ command-translate] [:div {:class (stl/css :shortcut-actions) :aria-labelledby (dm/str command-translate "-label")} - (if (and customized? (str/blank? content)) + ;; No key, whether the user removed it or the shortcut has none by + ;; default. + (if (str/blank? content) [:> icon* {:icon-id i/broken-link :size "s" :class (stl/css :shortcut-detach-icon)}] @@ -759,10 +761,14 @@ (when-let [default-cmd reset-notification] [:> context-notification* {:level :info :class (stl/css :modal-reset-msg)} (tr "shortcuts.edit-modal.reset-pending") - [:> shortcuts-keys* {:content default-cmd - :command (keyword "default") - :is-customized false - :has-conflict? false}]]) + (if (str/blank? default-cmd) + [:> icon* {:icon-id i/broken-link + :size "s" + :class (stl/css :shortcut-detach-icon)}] + [:> shortcuts-keys* {:content default-cmd + :command (keyword "default") + :is-customized false + :has-conflict? false}])]) (when (and recorded-command (not reset-pending)) (cond @@ -864,7 +870,9 @@ [:span {:class (stl/css :not-customizable-label)} "(not customizable)"])] [:div {:class (stl/css :shortcut-actions) :aria-labelledby (dm/str command-translate "-label")} - (if (and customized? (str/blank? content)) + ;; No key, whether the user removed it or the shortcut has none + ;; by default. + (if (str/blank? content) [:> tooltip* {:content (tr "shortcuts.disabled-shortcut") :trigger-ref trigger-ref :id (dm/str command-translate "-tooltip") diff --git a/frontend/test/frontend_tests/data/workspace_shortcuts_test.cljs b/frontend/test/frontend_tests/data/workspace_shortcuts_test.cljs index 6d498762a2..450bc0ddf4 100644 --- a/frontend/test/frontend_tests/data/workspace_shortcuts_test.cljs +++ b/frontend/test/frontend_tests/data/workspace_shortcuts_test.cljs @@ -162,3 +162,22 @@ (t/deftest move-shortcuts-cover-every-direction (t/is (= 8 (count (move-shortcuts shortcuts/shortcuts)))) (t/is (= 8 (count (move-shortcuts path-shortcuts/shortcuts))))) + +(def ^:private opacity-shortcut-ids + (mapv #(keyword (str "opacity-" %)) (range 10))) + +(t/deftest opacity-shortcuts-have-no-key-by-default + ;; https://github.com/penpot/penpot/issues/13303: typing a number with a + ;; shape selected changed its opacity by accident. + (doseq [id opacity-shortcut-ids] + (let [shortcut (get shortcuts/shortcuts id)] + (t/is (some? shortcut) (str id " still exists")) + (t/is (= "" (:command shortcut)) (str id " has no default key")) + (t/is (nil? (:tooltip shortcut)) (str id " shows no default key"))))) + +(t/deftest opacity-shortcuts-take-a-custom-key + (let [effective (ds/apply-custom-overrides shortcuts/shortcuts + {:workspace {:opacity-5 "5"}} + :workspace)] + (t/is (= "5" (get-in effective [:opacity-5 :command]))) + (t/is (= "" (get-in effective [:opacity-6 :command])))))