From dd0fb2e76b109caa1107bc78cc2a1f03ddef5865 Mon Sep 17 00:00:00 2001 From: =?utf8?q?John=20Molakvo=C3=A6?= Date: Wed, 27 Dec 2023 16:26:13 +0100 Subject: [PATCH] fix(files): open menu on right click position MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/src/components/FileEntry.vue | 16 ++++++++++++++++ .../components/FileEntry/FileEntryActions.vue | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue index 3ed8b0a5d4b..a6ca70d2800 100644 --- a/apps/files/src/components/FileEntry.vue +++ b/apps/files/src/components/FileEntry.vue @@ -353,6 +353,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 }, }, @@ -390,6 +399,13 @@ export default defineComponent({ return } + const root = this.$root.$el as HTMLElement + const contentRect = root.getBoundingClientRect() + // Using Math.min/max to prevent the menu from going out of the AppContent + // 200 = max width of the menu + root.style.setProperty('--mouse-pos-x', Math.max(contentRect.left, Math.min(event.clientX, event.clientX - 200)) + 'px') + root.style.setProperty('--mouse-pos-y', Math.max(contentRect.top, 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 diff --git a/apps/files/src/components/FileEntry/FileEntryActions.vue b/apps/files/src/components/FileEntry/FileEntryActions.vue index d4693b7d8e6..1e453fec706 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -327,8 +327,24 @@ export default Vue.extend({ }) - +