Skip to content

Commit 784d0bf

Browse files
susnuxbackportbot[bot]
authored andcommitted
fix(files): keep current folder on drag-n-drop
When drag and drop a file we only want to scroll to the uploaded file not changing the current view. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 6c3b99a commit 784d0bf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

apps/files/src/components/DragAndDropNotice.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<script lang="ts">
3030
import type { Folder } from '@nextcloud/files'
3131
import type { PropType } from 'vue'
32-
import type { RawLocation } from 'vue-router'
3332
3433
import { showError } from '@nextcloud/dialogs'
3534
import { Permission } from '@nextcloud/files'
@@ -111,7 +110,7 @@ export default defineComponent({
111110
mainContent.addEventListener('drop', this.onContentDrop)
112111
},
113112
114-
beforeDestroy() {
113+
beforeUnmount() {
115114
const mainContent = window.document.getElementById('app-content-vue') as HTMLElement
116115
mainContent.removeEventListener('dragover', this.onDragOver)
117116
mainContent.removeEventListener('dragleave', this.onDragLeave)
@@ -204,16 +203,19 @@ export default defineComponent({
204203
&& upload.source.replace(folder.source, '').split('/').length === 2)
205204
206205
if (lastUpload !== undefined) {
206+
const fileid = String(lastUpload.response!.headers['oc-fileid']).split(/(oc|nc)/, 2)[0]!
207207
logger.debug('Scrolling to last upload in current folder', { lastUpload })
208-
const location: RawLocation = {
209-
path: this.$route.path,
210-
// Keep params but change file id
208+
this.$router.push({
209+
name: this.$route.name!,
211210
params: {
211+
// Keep params but change file id
212212
...this.$route.params,
213-
fileid: String(lastUpload.response!.headers['oc-fileid']),
213+
fileid,
214214
},
215-
}
216-
this.$router.push(location)
215+
query: {
216+
dir: this.$route.query.dir,
217+
},
218+
})
217219
}
218220
219221
this.dragover = false

0 commit comments

Comments
 (0)