summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2023-09-04 23:43:53 +0100
committerfenn-cs <fenn25.fn@gmail.com>2023-09-07 10:54:47 +0100
commitf75684ec7e9eb1f3b4155f491e27e4d7ca2cc856 (patch)
tree622a76f91b9b3cc6edd69a8e9f324fafd28f0028 /apps
parent2b1008f2ce5ed77da1f5ad74a1ed3461f1bf47a1 (diff)
downloadnextcloud-server-f75684ec7e9eb1f3b4155f491e27e4d7ca2cc856.tar.gz
nextcloud-server-f75684ec7e9eb1f3b4155f491e27e4d7ca2cc856.zip
Close quickshare dropdown on outside click
If a user clicks anywhere outside of the quickshare dropdown, it should be closed. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue14
1 files changed, 13 insertions, 1 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue b/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
index 8128b3925ee..673038b620f 100644
--- a/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
+++ b/apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
@@ -1,5 +1,5 @@
<template>
- <div :class="{ 'active': showDropdown, 'share-select': true }">
+ <div :class="{ 'active': showDropdown, 'share-select': true }" ref="quickShareDropdown">
<span class="trigger-text" @click="toggleDropdown">
{{ selectedOption }}
<DropdownIcon :size="15" />
@@ -110,7 +110,12 @@ export default {
},
mounted() {
this.initializeComponent()
+ window.addEventListener('click', this.handleClickOutside);
},
+ beforeDestroy() {
+ // Remove the global click event listener to prevent memory leaks
+ window.removeEventListener('click', this.handleClickOutside);
+ },
methods: {
toggleDropdown() {
this.showDropdown = !this.showDropdown
@@ -128,6 +133,13 @@ export default {
initializeComponent() {
this.selectedOption = this.preSelectedOption
},
+ handleClickOutside(event) {
+ const dropdownElement = this.$refs.quickShareDropdown;
+
+ if (dropdownElement && !dropdownElement.contains(event.target)) {
+ this.showDropdown = false;
+ }
+ },
},
}