aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-08-31 18:17:32 +0200
committerGitHub <noreply@github.com>2024-08-31 18:17:32 +0200
commit25fbb9dafb2d58a124fb3f30011a1b6ed21721a3 (patch)
tree5c64169ec213f3d070bfe2888772682feee5becc /apps
parent95c70aab1a223ddcbd8dfbeafe0fa6416ef48163 (diff)
parent6ac090a3873a5fc124644b510da21c14fdd4d859 (diff)
downloadnextcloud-server-25fbb9dafb2d58a124fb3f30011a1b6ed21721a3.tar.gz
nextcloud-server-25fbb9dafb2d58a124fb3f30011a1b6ed21721a3.zip
Merge pull request #47639 from nextcloud/backport/47465/stable28
[stable28] fix(files): Reset drop notice on firefox
Diffstat (limited to 'apps')
-rw-r--r--apps/files/src/components/DragAndDropNotice.vue39
1 files changed, 32 insertions, 7 deletions
diff --git a/apps/files/src/components/DragAndDropNotice.vue b/apps/files/src/components/DragAndDropNotice.vue
index 40f95f54aeb..6af333eb660 100644
--- a/apps/files/src/components/DragAndDropNotice.vue
+++ b/apps/files/src/components/DragAndDropNotice.vue
@@ -45,11 +45,14 @@
<script lang="ts">
import type { Folder } from '@nextcloud/files'
+import type { RawLocation } from 'vue-router'
+
import { Permission } from '@nextcloud/files'
import { showError } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import { UploadStatus } from '@nextcloud/upload'
import { defineComponent, type PropType } from 'vue'
+import debounce from 'debounce'
import TrayArrowDownIcon from 'vue-material-design-icons/TrayArrowDown.vue'
@@ -104,18 +107,29 @@ export default defineComponent({
}
return null
},
+
+ /**
+ * Debounced function to reset the drag over state
+ * Required as Firefox has a bug where no dragleave is emitted:
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=656164
+ */
+ resetDragOver() {
+ return debounce(() => {
+ this.dragover = false
+ }, 3000)
+ },
},
mounted() {
// Add events on parent to cover both the table and DragAndDrop notice
- const mainContent = window.document.querySelector('main.app-content') as HTMLElement
+ const mainContent = window.document.getElementById('app-content-vue') as HTMLElement
mainContent.addEventListener('dragover', this.onDragOver)
mainContent.addEventListener('dragleave', this.onDragLeave)
mainContent.addEventListener('drop', this.onContentDrop)
},
beforeDestroy() {
- const mainContent = window.document.querySelector('main.app-content') as HTMLElement
+ const mainContent = window.document.getElementById('app-content-vue') as HTMLElement
mainContent.removeEventListener('dragover', this.onDragOver)
mainContent.removeEventListener('dragleave', this.onDragLeave)
mainContent.removeEventListener('drop', this.onContentDrop)
@@ -130,6 +144,7 @@ export default defineComponent({
if (isForeignFile) {
// Only handle uploading of outside files (not Nextcloud files)
this.dragover = true
+ this.resetDragOver()
}
},
@@ -144,6 +159,7 @@ export default defineComponent({
if (this.dragover) {
this.dragover = false
+ this.resetDragOver.clear()
}
},
@@ -152,6 +168,7 @@ export default defineComponent({
event.preventDefault()
if (this.dragover) {
this.dragover = false
+ this.resetDragOver.clear()
}
},
@@ -204,16 +221,24 @@ export default defineComponent({
if (lastUpload !== undefined) {
logger.debug('Scrolling to last upload in current folder', { lastUpload })
- this.$router.push({
- ...this.$route,
+ const location: RawLocation = {
+ path: this.$route.path,
+ // Keep params but change file id
params: {
- view: this.$route.params?.view ?? 'files',
- fileid: parseInt(lastUpload.response!.headers['oc-fileid']),
+ ...this.$route.params,
+ fileid: String(lastUpload.response!.headers['oc-fileid']),
+ },
+ query: {
+ ...this.$route.query,
},
- })
+ }
+ // Remove open file from query
+ delete location.query.openfile
+ this.$router.push(location)
}
this.dragover = false
+ this.resetDragOver.clear()
},
t,