fix: Register default file action to prevent download instead of open#5366
Open
fix: Register default file action to prevent download instead of open#5366
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.