Skip to content

Commit 7ac1e2f

Browse files
authored
Merge pull request #45586 from nextcloud/fix/files-default-action
2 parents c1661b6 + 923e1b8 commit 7ac1e2f

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

apps/files/src/components/FilesListVirtual.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,18 @@ export default defineComponent({
259259
260260
logger.debug('Opening file ' + node.path, { node })
261261
this.openFileId = fileId
262-
getFileActions()
263-
.filter(action => !action.enabled || action.enabled([node], this.currentView))
262+
const defaultAction = getFileActions()
263+
// Get only default actions (visible and hidden)
264+
.filter(action => !!action?.default)
265+
// Find actions that are either always enabled or enabled for the current node
266+
.filter((action) => !action.enabled || action.enabled([node], this.currentView))
267+
// Sort enabled default actions by order
264268
.sort((a, b) => (a.order || 0) - (b.order || 0))
265-
.filter(action => !!action?.default)[0].exec(node, this.currentView, this.currentFolder.path)
266-
},
267-
268-
getFileId(node) {
269-
return node.fileid
269+
// Get the first one
270+
.at(0)
271+
// Some file types do not have a default action (e.g. they can only be downloaded)
272+
// So if there is an enabled default action, so execute it
273+
defaultAction?.exec(node, this.currentView, this.currentFolder.path)
270274
},
271275
272276
onDragOver(event: DragEvent) {

dist/files-main.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)