Skip to content

Commit 25fbb9d

Browse files
authored
Merge pull request #47639 from nextcloud/backport/47465/stable28
[stable28] fix(files): Reset drop notice on firefox
2 parents 95c70aa + 6ac090a commit 25fbb9d

3 files changed

Lines changed: 35 additions & 10 deletions

File tree

apps/files/src/components/DragAndDropNotice.vue

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@
4545

4646
<script lang="ts">
4747
import type { Folder } from '@nextcloud/files'
48+
import type { RawLocation } from 'vue-router'
49+
4850
import { Permission } from '@nextcloud/files'
4951
import { showError } from '@nextcloud/dialogs'
5052
import { translate as t } from '@nextcloud/l10n'
5153
import { UploadStatus } from '@nextcloud/upload'
5254
import { defineComponent, type PropType } from 'vue'
55+
import debounce from 'debounce'
5356
5457
import TrayArrowDownIcon from 'vue-material-design-icons/TrayArrowDown.vue'
5558
@@ -104,18 +107,29 @@ export default defineComponent({
104107
}
105108
return null
106109
},
110+
111+
/**
112+
* Debounced function to reset the drag over state
113+
* Required as Firefox has a bug where no dragleave is emitted:
114+
* https://bugzilla.mozilla.org/show_bug.cgi?id=656164
115+
*/
116+
resetDragOver() {
117+
return debounce(() => {
118+
this.dragover = false
119+
}, 3000)
120+
},
107121
},
108122
109123
mounted() {
110124
// Add events on parent to cover both the table and DragAndDrop notice
111-
const mainContent = window.document.querySelector('main.app-content') as HTMLElement
125+
const mainContent = window.document.getElementById('app-content-vue') as HTMLElement
112126
mainContent.addEventListener('dragover', this.onDragOver)
113127
mainContent.addEventListener('dragleave', this.onDragLeave)
114128
mainContent.addEventListener('drop', this.onContentDrop)
115129
},
116130
117131
beforeDestroy() {
118-
const mainContent = window.document.querySelector('main.app-content') as HTMLElement
132+
const mainContent = window.document.getElementById('app-content-vue') as HTMLElement
119133
mainContent.removeEventListener('dragover', this.onDragOver)
120134
mainContent.removeEventListener('dragleave', this.onDragLeave)
121135
mainContent.removeEventListener('drop', this.onContentDrop)
@@ -130,6 +144,7 @@ export default defineComponent({
130144
if (isForeignFile) {
131145
// Only handle uploading of outside files (not Nextcloud files)
132146
this.dragover = true
147+
this.resetDragOver()
133148
}
134149
},
135150
@@ -144,6 +159,7 @@ export default defineComponent({
144159
145160
if (this.dragover) {
146161
this.dragover = false
162+
this.resetDragOver.clear()
147163
}
148164
},
149165
@@ -152,6 +168,7 @@ export default defineComponent({
152168
event.preventDefault()
153169
if (this.dragover) {
154170
this.dragover = false
171+
this.resetDragOver.clear()
155172
}
156173
},
157174
@@ -204,16 +221,24 @@ export default defineComponent({
204221
205222
if (lastUpload !== undefined) {
206223
logger.debug('Scrolling to last upload in current folder', { lastUpload })
207-
this.$router.push({
208-
...this.$route,
224+
const location: RawLocation = {
225+
path: this.$route.path,
226+
// Keep params but change file id
209227
params: {
210-
view: this.$route.params?.view ?? 'files',
211-
fileid: parseInt(lastUpload.response!.headers['oc-fileid']),
228+
...this.$route.params,
229+
fileid: String(lastUpload.response!.headers['oc-fileid']),
230+
},
231+
query: {
232+
...this.$route.query,
212233
},
213-
})
234+
}
235+
// Remove open file from query
236+
delete location.query.openfile
237+
this.$router.push(location)
214238
}
215239
216240
this.dragover = false
241+
this.resetDragOver.clear()
217242
},
218243
219244
t,

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)