Skip to content

feat(viewer): tell the handler when its file is on screen - #156

Merged
skjnldsv merged 4 commits into
mainfrom
feat/focus-shown-file
Oct 21, 2026
Merged

skjnldsv merged 4 commits into
mainfrom
feat/focus-shown-file

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Handlers get a new shown prop: true once their file has loaded and is on screen. A handler that wants its own content focused (an editor's text, say) can watch it, since in onMounted the element is still hidden. When comparing, only the newer file gets it.

On close, focus goes back to whatever opened the viewer, even if a handler took it before the modal's focus trap started.

The builtin handlers use it: videos and sounds give the keyboard to their player, image differences to their slider.

Fixes nextcloud/viewer#860

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

@skjnldsv skjnldsv added this to the 2.0.0 milestone Oct 20, 2026
@skjnldsv skjnldsv self-assigned this Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.71%. Comparing base (16830cb) to head (00e1211).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   92.64%   92.71%   +0.07%     
==========================================
  Files          51       51              
  Lines        4229     4270      +41     
  Branches      943      951       +8     
==========================================
+ Hits         3918     3959      +41     
  Misses        288      288              
  Partials       23       23              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@skjnldsv
skjnldsv force-pushed the feat/focus-shown-file branch 2 times, most recently from 4e6053a to c8f0377 Compare October 20, 2026 10:06
@skjnldsv skjnldsv changed the title feat(viewer): give the keyboard to the file shown feat(viewer): tell the handler when its file is on screen Oct 20, 2026
@skjnldsv
skjnldsv force-pushed the feat/focus-shown-file branch from dff873e to b71bfe1 Compare October 21, 2026 07:40
A handler that wants its own content focused, an editor's text say,
watches the new shown prop: true once the file has loaded and is on
screen, where in onMounted its element is still hidden. When comparing,
only the newer file's element gets it.

The viewer gives the keyboard back to what opened it on close if
nothing has it: a handler that focused before the modal's focus trap
started left the trap nothing to give back.

The before-download example now declares what it uses.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
v-show lifts its display: none at the end of the update, after the
handler had already been told: a handler focusing its content then
focused nothing.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
A video or a sound gives it to its skin, so Space, m, j, l and the
volume keys reach the player while the arrows still step through the
files. The skin rather than its container: the modal's focus trap
takes back a focus in a shadow root found before it started. Image
differences give it to the slider, which the arrows then move.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
@skjnldsv
skjnldsv force-pushed the feat/focus-shown-file branch 3 times, most recently from 8c46bc6 to 6b5ade3 Compare October 21, 2026 08:29
Whether a sound plays depends on a sound device: check the player was
asked to play or pause it instead. Firefox without one, as in CI,
plays nothing and its player takes no shortcut then, so the check is
skipped there.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
@skjnldsv
skjnldsv force-pushed the feat/focus-shown-file branch from 6b5ade3 to 00e1211 Compare October 21, 2026 08:29
@skjnldsv
skjnldsv merged commit 82b3693 into main Oct 21, 2026
20 checks passed
@skjnldsv
skjnldsv deleted the feat/focus-shown-file branch October 21, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navigating via keyboard and opening photos, Viewer does not take focus, and resets focus to beginning of Files list after closing

1 participant