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>
@juliusknorr
Copy link
Member

This approach seems more like a workaround. Can you tell how you replicated this and if it was specific to a nextcloud version? Last week #5355 was raised as we missed that backport for 32 it seemed. #4983 was the pr for master and is supposed to fix exactly the issue you mentioned.

@juliusknorr juliusknorr added the bug Something isn't working label Feb 17, 2026
@timar
Copy link
Member Author

timar commented Feb 17, 2026

This approach seems more like a workaround. Can you tell how you replicated this and if it was specific to a nextcloud version? Last week #5355 was raised as we missed that backport for 32 it seemed. #4983 was the pr for master and is supposed to fix exactly the issue you mentioned.

Yes, it's sort of a hack. I tried to fix the underlying timing issue in viewer, but I failed. I'm happy if you fixed it properly in a different way. We always had this issue with different versions, but I debugged and tested my fix with Nextcloud 33.0.0 RC4 and richdocuments 10.0.0-beta.1.
It's not 100% reproducible, sometimes when you load the Files view, the click on files download them instead of opening in COOL. The bug disappears, if we enter a subdirectory. It also disappears, if we reload the page 1-4 times. And sometimes file opening works immediately.
With this hack I submitted, the bug was 100% not reproducible.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments