Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
type="tertiary"
:force-menu="enabledInlineActions.length === 0 /* forceMenu only if no inline actions */"
:inline="enabledInlineActions.length"
:open.sync="openedMenu"
@close="openedSubmenu = null">
:open="openedMenu"
@close="onMenuClose"
@closed="onMenuClosed">
<!-- Default actions list-->
<NcActionButton v-for="action, index in enabledMenuActions"
:key="action.id"
Expand Down Expand Up @@ -230,7 +231,7 @@ export default defineComponent({
},

watch: {
// Close any submenu when the menu is closed
// Close any submenu when the menu state changes
openedMenu() {
this.openedSubmenu = null
},
Expand Down Expand Up @@ -302,6 +303,20 @@ export default defineComponent({
this.openedMenu = true
}
},

onMenuClose() {
// We reset the submenu state when the menu is closing
this.openedSubmenu = null
},

onMenuClosed() {
// TODO: remove timeout once https://github.com/nextcloud-libraries/nextcloud-vue/pull/6683 is merged
// and updated on server.
setTimeout(() => {
// We reset the actions menu state when the menu is finally closed
this.openedMenu = false
}, 100)
},
},
})
</script>
Expand Down
37 changes: 21 additions & 16 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@ export default defineComponent({
return this.actionsMenuStore.opened === this.uniqueId.toString()
},
set(opened) {
this.actionsMenuStore.opened = opened ? this.uniqueId.toString() : null
// If the menu is opened on another file entry, we ignore closed events
if (opened === false && this.actionsMenuStore.opened !== this.uniqueId.toString()) {
return
}

// If opened, we specify the current file id
// else we set it to null to close the menu
this.actionsMenuStore.opened = opened
? this.uniqueId.toString()
: null
},
},

Expand Down Expand Up @@ -235,21 +244,16 @@ export default defineComponent({
},

openedMenu() {
if (this.openedMenu === false) {
// TODO: This timeout can be removed once `close` event only triggers after the transition
// ref: https://github.com/nextcloud-libraries/nextcloud-vue/pull/6065
window.setTimeout(() => {
if (this.openedMenu) {
// was reopened while the animation run
return
}
// Reset any right menu position potentially set
const root = document.getElementById('app-content-vue')
if (root !== null) {
root.style.removeProperty('--mouse-pos-x')
root.style.removeProperty('--mouse-pos-y')
}
}, 300)
// Checking if the menu is really closed and not
// just a change in the open state to another file entry.
if (this.actionsMenuStore.opened === null) {
// Reset any right menu position potentially set
logger.debug('All actions menu closed, resetting right menu position...')
const root = this.$el?.closest('main.app-content') as HTMLElement
if (root !== null) {
root.style.removeProperty('--mouse-pos-x')
root.style.removeProperty('--mouse-pos-y')
}
}
},
},
Expand Down Expand Up @@ -282,6 +286,7 @@ export default defineComponent({
const contentRect = root.getBoundingClientRect()
// Using Math.min/max to prevent the menu from going out of the AppContent
// 200 = max width of the menu
logger.debug('Setting actions menu position...')
root.style.setProperty('--mouse-pos-x', Math.max(0, event.clientX - contentRect.left - 200) + 'px')
root.style.setProperty('--mouse-pos-y', Math.max(0, event.clientY - contentRect.top) + 'px')
} else {
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

Loading