Skip to content

fix: Register default file action to prevent download instead of open#5366

Open
timar wants to merge 1 commit intomainfrom
private/timar/fixrace
Open

fix: Register default file action to prevent download instead of open#5366
timar wants to merge 1 commit intomainfrom
private/timar/fixrace

Conversation

@timar
Copy link
Member

@timar timar commented Feb 13, 2026

The Viewer app's 'view' file action checks window.OCA.Viewer.mimetypes to decide if it can handle a file. However, those mimetypes are only populated on DOMContentLoaded when handlers are bridged from the @nextcloud/viewer npm package to the ViewerService. If the Files app renders the file list before that event fires, the 'view' action's enabled() returns false and the 'download' action (order 30) becomes the default — causing document files to be downloaded instead of opened in Collabora Online.

Register a richdocuments-specific default file action that checks against the OCS capability mimetype list (baked into the page HTML via initial state, always available immediately) instead of the ViewerService's runtime mimetypes. When the Viewer's 'view' action works correctly both actions are enabled but 'view' wins (registered first). When 'view' is disabled due to the timing race, the new action takes over. Execution delegates to the Viewer's own 'view' action for proper URL history and prev/next navigation support.

The Viewer app's 'view' file action checks window.OCA.Viewer.mimetypes
to decide if it can handle a file. However, those mimetypes are only
populated on DOMContentLoaded when handlers are bridged from the
@nextcloud/viewer npm package to the ViewerService. If the Files app
renders the file list before that event fires, the 'view' action's
enabled() returns false and the 'download' action (order 30) becomes
the default — causing document files to be downloaded instead of
opened in Collabora Online.

Register a richdocuments-specific default file action that checks
against the OCS capability mimetype list (baked into the page HTML
via initial state, always available immediately) instead of the
ViewerService's runtime mimetypes. When the Viewer's 'view' action
works correctly both actions are enabled but 'view' wins (registered
first). When 'view' is disabled due to the timing race, the new
action takes over. Execution delegates to the Viewer's own 'view'
action for proper URL history and prev/next navigation support.

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant