Skip to content

Conversation

@ShGKme
Copy link
Contributor

@ShGKme ShGKme commented Aug 27, 2025

☑️ Resolves

  • Ref: [Meta] Forms design improvement #7124
  • First component for keyboard shortcuts — replacement for <kbd>
    • Custom styling
    • Localized key names
    • Auto icons
    • macOS handling
    • Custom slot for customisation

Note: complete form will have an additional component for an entire keyboard shortcut list

🖼️ Screenshots

Windows

image

macOS

image

🏁 Checklist

  • ⛑️ Tests are included or are not applicable
  • 📘 Component documentation has been extended, updated or is not applicable
  • 2️⃣ Backport to stable8 for maintained Vue 2 version or not applicable

@ShGKme ShGKme added this to the 9.0.0-rc.7 milestone Aug 27, 2025
@ShGKme ShGKme self-assigned this Aug 27, 2025
@ShGKme ShGKme added enhancement New feature or request 2. developing Work in progress labels Aug 27, 2025
@ShGKme ShGKme added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Aug 28, 2025
@ShGKme ShGKme marked this pull request as ready for review August 28, 2025 09:47
@ShGKme ShGKme requested a review from susnux August 28, 2025 09:49
Escape: !mac
? t('Escape') // TRANSLATORS: Escape key on keyboard
: '⎋',
Space: t('Space'), // TRANSLATORS: Space key on keyboard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we sometimes use icons for them, maybe use this for space?
https://pictogrammers.com/library/mdi/icon/keyboard-space/

its quite common, no? cc @nextcloud-libraries/designers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never use icons (images). It was discussed with @kra-mo that symbols look fine on macOS.

Same for the space — even though there is a symbol, it was decided to use a word here.

image

Copy link
Contributor

@Antreesy Antreesy Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely would put it for mac, otherwise it stands out too much.
Also might be less confusion for translators. That's usually the only button that doesn't have a text on a physical keyboard, and also the one i would translate out of all other

UPD: maybe this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it will look silly translated like in German I rarely see this like

[Strg] + [Leertaste]

I would expect the icon for the space key as it does not has any label on the keyboard.
But also for the other icons you added for Mac, are you sure they work for screen readers? If not maybe just use icons and add aria label with the real name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test these symbols specifically, but usually it works well with screen readers.
I'd prefer to use symbols to safe from translating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also add a comment for translator to translate it only if it is a common practice.

E.g., CTRL almost never translated in Russian.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, I think the word Space is still more well-recognized internationally than the symbol, but I might be wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you show some example in an app on Linux?

E.g.:

grafik

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least everything is better than the firefox and thunderbird shortcuts help which uses really silly names...
If you both did not see the symbol that often then its probably fine, it just stands out quite visible for MacOS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just stands out quite visible for MacOS

I do agree that it does, but for macOS specifically, it's just about following platform conventions

Copy link
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space as icon or as text is a @nextcloud-libraries/designers decision, while I rarely saw a label used (especially translated) its probably ok.
So I let this up to the designers - code is fine!

Copy link
Contributor

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise good

ShGKme added 2 commits August 28, 2025 14:27
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
@ShGKme
Copy link
Contributor Author

ShGKme commented Aug 28, 2025

Rebased onto main, squashed

@ShGKme
Copy link
Contributor Author

ShGKme commented Aug 28, 2025

If we decied to use an icon for the space, we can update it later without a breaking change.

Comment on lines +17 to +21
/**
* Key name or symbol to display.
* For common special keys (CTRL, ALT, SHIFT, Arrow keys, etc.) it will display the symbol on macOS and the localized name on Windows/Linux.
*/
symbol?: 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | 'Control' | 'Alt' | 'Shift' | 'Enter' | 'Space' | 'Tab' | 'Delete' | 'Escape' | (string & {})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case before merging.

@susnux Are you fine with this prop name?
(key cannot be used as it is a special attribute).
Alternative: keyname, keycode (but it has a different meaning in web api), code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you also write "Key name" as the doc I think keyname is pretty good.
But also symbol seems to fit here so you can merged if you like ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But proper name would be keyName which would be <NcKbd key-name="..." /> maybe stick with symbol instead 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Antreesy Do I remember it correctly, that in useHotKey the preferred way to set a key is the keyCode (like KeyF, not F)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it takes F and then checks if key is equal (e.g. F === F) otherwise falls back to get the keyCode and removes the Key or Digit and then compares

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just F would be preferable, as we can then derive the keyCode from it

@ShGKme ShGKme merged commit 69d410c into main Aug 28, 2025
25 checks passed
@ShGKme ShGKme deleted the feat/NcKbd branch August 28, 2025 19:16
@ShGKme
Copy link
Contributor Author

ShGKme commented Aug 28, 2025

/backport to stable1

@backportbot
Copy link

backportbot bot commented Aug 28, 2025

The backport to stable1 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable1
git pull origin stable1

# Create the new backport branch
git checkout -b backport/7401/stable1

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick deaebab5 0e596d41

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/7401/stable1

Error: Failed to clone repository: Failed to create working tree: Preparing worktree (new branch 'backport/7401/stable1')
fatal: not a valid object name: 'origin/stable1'


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@susnux
Copy link
Contributor

susnux commented Aug 28, 2025

backport to stable1

Quite old branch ;)

@susnux
Copy link
Contributor

susnux commented Aug 28, 2025

/backport to stable8

@ShGKme
Copy link
Contributor Author

ShGKme commented Aug 28, 2025

Quite old branch ;)

I'm tired 😴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants