Skip to content

[Bug] Closing a file preview calls a missing Files Sidebar method #3446

Closed

Description

@sashalab

Environment

  • Nextcloud Server 35.0.2, official Apache Docker image
  • Bundled Viewer 8.0.0
  • Chromium with a 390 × 844 mobile viewport and touch emulation
  • Reproduced with custom CSS disabled and by accessing Nextcloud directly, without proxy HTML injection or modified JavaScript

Steps to reproduce

  1. Open Files and preview a PNG image.
  2. Close the preview using its close button.
  3. Inspect the browser console.

Actual result

Viewer.close() throws TypeError: OCA.Files.Sidebar.setFullScreenMode is not a function.

Image preview and download work. A PDF can be opened after the close transition finishes, so this report does not claim that subsequent previews are consistently blocked.

Expected result

Closing the preview completes without an exception when this optional Files Sidebar method is unavailable.

Suspected cause

The close handler checks that OCA.Files.Sidebar exists, but does not check whether setFullScreenMode is callable. beforeOpen() already checks for the method's presence. The same unsafe close call is still present in current master:
https://github.com/nextcloud/viewer/blob/master/src/views/Viewer.vue#L967-L979

A callable guard around the close-time invocation should preserve compatibility with both Sidebar APIs and allow the following fullscreen cleanup to run.

Minimal proposed fix and focused check

Against viewer commit d0d68b960285c820cc69e7eb05d68d9a98555230:

- if (OCA?.Files?.Sidebar) {
+ if (typeof OCA?.Files?.Sidebar?.setFullScreenMode === 'function') {
    OCA.Files.Sidebar.setFullScreenMode(false)
  }

A Node VM check using the actual extracted close() method reproduces the exception on the baseline (and skipped fullscreen exit), then passes with a missing method, missing Files API, and callable legacy method. The legacy method receives false with its original receiver. This is a focused method check, not a full Vue build or integration test.

Activity

  1. susnux commented on Oct 25, 2026

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3. to reviewWaiting for reviewsbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions