Skip to content

Commit

Permalink
fix(files): open menu on right click position
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Dec 27, 2023
1 parent fc7e643 commit d409681
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
14 changes: 14 additions & 0 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ export default defineComponent({
return this.actionsMenuStore.opened === this.uniqueId
},
set(opened) {
// Only reset when opening a new menu
if (opened) {
// Reset any right click position override on close
// Wait for css animation to be done
const root = this.$root.$el as HTMLElement
root.style.removeProperty('--mouse-pos-x')
root.style.removeProperty('--mouse-pos-y')
}

this.actionsMenuStore.opened = opened ? this.uniqueId : null
},
},
Expand Down Expand Up @@ -389,6 +398,11 @@ export default defineComponent({
return
}

const root = this.$root.$el as HTMLElement
const contentRect = root.getBoundingClientRect()
root.style.setProperty('--mouse-pos-x', event.clientX - contentRect.left + 'px')
root.style.setProperty('--mouse-pos-y', event.clientY - contentRect.top + 'px')

// If the clicked row is in the selection, open global menu
const isMoreThanOneSelected = this.selectedFiles.length > 1
this.actionsMenuStore.opened = this.isSelected && isMoreThanOneSelected ? 'global' : this.uniqueId
Expand Down
18 changes: 17 additions & 1 deletion apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,24 @@ export default Vue.extend({
})
</script>

<style lang="scss" scoped>
<style lang="scss">
// Allow right click to define the position of the menu
// only if defined
.app-content[style*="mouse-pos-x"] .v-popper__popper {
transform: translate3d(var(--mouse-pos-x), var(--mouse-pos-y), 0px) !important;

// If the menu is too close to the bottom, we move it up
&[data-popper-placement="top"] {
transform: translate3d(var(--mouse-pos-x), calc(var(--mouse-pos-y) - 50vh), 0px) !important;
}
// Hide arrow if floating
.v-popper__arrow-container {
display: none;
}
}
</style>

<style lang="scss" scoped>
:deep(.button-vue--icon-and-text, .files-list__row-action-sharing-status) {
.button-vue__text {
color: var(--color-primary-element);
Expand Down

0 comments on commit d409681

Please sign in to comment.