✨ Leave the opacity shortcuts without a default key (#13309)

* ✨ 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

* 📚 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
This commit is contained in:
Eva Marco 2026-11-26 14:19:30 +01:00 committed by GitHub
parent 58d35aae98
commit b80456b607
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 75 deletions

View File

@ -37,7 +37,6 @@ desc: Get quickstart tips, shortcuts, and tutorials for Penpot! Learn interface
<h3 id="customize-shortcuts-layouts">Keyboard layouts</h3>
<p>Letters are recorded by the character they type, so they follow your layout (on AZERTY, the <kbd>A</kbd> key records <kbd>a</kbd>). With <kbd>Shift</kbd>, <kbd>Alt</kbd> or another modifier, letter and digit keys record the key itself, not the character the modifier makes (<kbd>Shift</kbd><kbd>0</kbd>, not <kbd>Shift</kbd><kbd>)</kbd>; <kbd>⌥</kbd><kbd>M</kbd> on macOS, not <kbd>µ</kbd>).</p>
<p>Punctuation keys (such as <kbd>-</kbd>, <kbd>[</kbd>, <kbd>/</kbd> or <kbd>'</kbd>) are recorded by their physical position on the keyboard, so <kbd>Shift</kbd> with the <kbd>+</kbd> key records <kbd>Shift</kbd><kbd>+</kbd> 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 <kbd>AltGr</kbd> record the character they type (<kbd>\</kbd> on a Spanish layout).</p>
<p>One known limitation: number keys set opacity (<kbd>0</kbd>–<kbd>9</kbd>) only where digits are typed without <kbd>Shift</kbd>, so AZERTY layouts need the numeric keypad for them.</p>
<h3 id="customize-shortcuts-reset">Reset to default</h3>
<p>When you have custom shortcuts, a <strong>Reset all</strong> button appears next to the search field. It lists every shortcut that will go back to its default before you confirm.</p>
@ -399,54 +398,8 @@ desc: Get quickstart tips, shortcuts, and tutorials for Penpot! Learn interface
</tr>
<tr>
<td>Set opacity to 10%</td>
<td style="text-align: center;"><kbd>1</kbd></td>
<td style="text-align: center;"><kbd>1</kbd></td>
</tr>
<tr>
<td>Set opacity to 20%</td>
<td style="text-align: center;"><kbd>2</kbd></td>
<td style="text-align: center;"><kbd>2</kbd></td>
</tr>
<tr>
<td>Set opacity to 30%</td>
<td style="text-align: center;"><kbd>3</kbd></td>
<td style="text-align: center;"><kbd>3</kbd></td>
</tr>
<tr>
<td>Set opacity to 40%</td>
<td style="text-align: center;"><kbd>4</kbd></td>
<td style="text-align: center;"><kbd>4</kbd></td>
</tr>
<tr>
<td>Set opacity to 50%</td>
<td style="text-align: center;"><kbd>5</kbd></td>
<td style="text-align: center;"><kbd>5</kbd></td>
</tr>
<tr>
<td>Set opacity to 60%</td>
<td style="text-align: center;"><kbd>6</kbd></td>
<td style="text-align: center;"><kbd>6</kbd></td>
</tr>
<tr>
<td>Set opacity to 70%</td>
<td style="text-align: center;"><kbd>7</kbd></td>
<td style="text-align: center;"><kbd>7</kbd></td>
</tr>
<tr>
<td>Set opacity to 80%</td>
<td style="text-align: center;"><kbd>8</kbd></td>
<td style="text-align: center;"><kbd>8</kbd></td>
</tr>
<tr>
<td>Set opacity to 90%</td>
<td style="text-align: center;"><kbd>9</kbd></td>
<td style="text-align: center;"><kbd>9</kbd></td>
</tr>
<tr>
<td>Set opacity to 100%</td>
<td style="text-align: center;"><kbd>0</kbd></td>
<td style="text-align: center;"><kbd>0</kbd></td>
<td>Set opacity to 10%, 20%… 100%</td>
<td colspan="2" style="text-align: center;">No default keys. Assign them in <a href="#customize-shortcuts">Customize shortcuts</a>.</td>
</tr>
<tr>
<td>Ungroup</td>

View File

@ -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))}})

View File

@ -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")

View File

@ -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])))))