Skip to content

Clear openfile before unwinding the history, not after - #43

Merged
skjnldsv merged 1 commit into
mainfrom
fix/close-clears-openfile-first
Sep 17, 2026
Merged

skjnldsv merged 1 commit into
mainfrom
fix/close-clears-openfile-first

Conversation

@skjnldsv

Copy link
Copy Markdown
Contributor

Closing the viewer unwinds the history entries it pushed with history.go(-offset), which lands on a later task. Until it lands the URL still carries openfile=true, and FilesListVirtual.handleOpenQueries() runs the default action for exactly that flag. Anything that makes the Files list re-read the route inside that window opens a second viewer over the one that is closing.

It shows up on a shared CI runner, where the window is wide enough to hit. Three media tests in nextcloud/server#63954 failed their close assertion, all the same way:

Error: expect(locator).toBeHidden() failed
Locator: locator('.viewer__modal').locator('.modal-container')
  4 × locator resolved to <div class="modal-container" id="modal-description-nc-vue-6">
 10 × locator resolved to <div class="modal-container" id="modal-description-nc-vue-8">

Two containers, one per viewer instance. Probing the DOM against a real server shows the window plainly: right after the close button is clicked there is still one modal and the URL still says openfile=true; a second later the modal is gone and the flag with it.

OPEN     roots:1 containers:1 mounts:1   url=…/files/26?dir=/&openfile=true
CLICKED  roots:1 containers:1 mounts:1   url=…/files/26?dir=/&openfile=true
SETTLED  roots:0 containers:0 mounts:1   url=…/files

The flag now comes off the entry being left before the jump is requested, so there is no window where the URL asks for a file that the viewer is busy closing. The refresh-opened case already did this and is unchanged.

The new unit test pins the order rather than just the outcome: goToRoute before history.go, since doing it the other way round is what the bug was. It fails on main.

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

Closing the viewer jumps back past the entries it pushed, and
history.go() lands on a later task. Until it does, the URL still says
openfile=true, and the Files list runs the default action again for
anything that makes it re-read the route in that window: a second
viewer opens over the one that is closing.

Seen on a shared CI runner, where the window is wide: three media tests
failed on their close assertion with two modal containers in the DOM,
one per viewer. The flag now comes off the entry being left before the
jump is asked for.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv added status: review Waiting for reviews type: bug 🐛 Something isn't working AI assisted labels Sep 17, 2026
@skjnldsv
skjnldsv merged commit b23defd into main Sep 17, 2026
14 checks passed
@skjnldsv
skjnldsv deleted the fix/close-clears-openfile-first branch September 17, 2026 20:14
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.99%. Comparing base (95e0fd6) to head (518c343).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #43   +/-   ##
=======================================
  Coverage   87.99%   87.99%           
=======================================
  Files          36       36           
  Lines        2507     2508    +1     
  Branches      524      525    +1     
=======================================
+ Hits         2206     2207    +1     
  Misses        297      297           
  Partials        4        4           

☔ 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.

@skjnldsv skjnldsv mentioned this pull request Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted status: review Waiting for reviews type: bug 🐛 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant