nextcloud-libraries / nextcloud-libraries/nextcloud-viewer

Keyboard shortcuts were lost in the rewrite

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

AI assisted status: triage type: bug
Dominant language
TypeScript
Stars
1
Forks
0
Avg merge
6h 19m
Merged PRs (30d)
43

Description

The viewer this one replaced bound three shortcuts on window while it was open:

keyboardDeleteFile(event) {
  if (this.canDelete && event.key === 'Delete' && event.ctrlKey === true) this.onDelete()
}
keyboardDownloadFile(event) {
  if (event.key === 's' && event.ctrlKey === true) { event.preventDefault(); if (this.canDownload) this.onDownload() }
}
keyboardEditFile(event) {
  if (event.key === 'e' && event.ctrlKey === true) { event.preventDefault(); if (this.canEdit) this.onEdit() }
}

There is no keyboard handling of any kind in the library now — grep for addEventListener('key, @keydown and useHotKey across lib/ returns nothing.

Worth checking before reimplementing them here: the download and delete actions are rendered from the Files actions registry now rather than being the viewer's own buttons, so those two may already register their own shortcuts. If they do, only edit needs one, and it should be registered the way the rest of the frontend does it rather than as a bare window listener.

Edit also has a condition it did not have before: it is now gated on the file's write permission, so a shortcut has to respect that too.

  • Check whether the Files actions already bind Ctrl+S and Ctrl+Delete
  • Reimplement what is missing, using the frontend's own hotkey mechanism
  • Cover them, in the playground where the actions exist

Found while reading the old viewer for regressions; the others from that pass are fixed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the Files actions registry and the frontend hotkey mechanism, then grep lib/ for existing keyboard handling and check the playground where the actions exist. Verify whether Ctrl+S and Ctrl+Delete are already registered; implement only missing shortcuts, including edit with its write-permission condition. Done means the relevant shortcuts work and are covered in the playground.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.