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>
This commit is contained in:
Ferdinand Thiessen 2026-02-02 10:36:43 +01:00
parent 4775ce4266
commit 1f6fe21527
No known key found for this signature in database
GPG key ID: 7E849AE05218500F

View file

@ -29,7 +29,6 @@
<script lang="ts">
import type { Folder } from '@nextcloud/files'
import type { PropType } from 'vue'
import type { RawLocation } from 'vue-router'
import { showError } from '@nextcloud/dialogs'
import { Permission } from '@nextcloud/files'
@ -111,7 +110,7 @@ export default defineComponent({
mainContent.addEventListener('drop', this.onContentDrop)
},
beforeDestroy() {
beforeUnmount() {
const mainContent = window.document.getElementById('app-content-vue') as HTMLElement
mainContent.removeEventListener('dragover', this.onDragOver)
mainContent.removeEventListener('dragleave', this.onDragLeave)
@ -204,16 +203,19 @@ export default defineComponent({
&& upload.source.replace(folder.source, '').split('/').length === 2)
if (lastUpload !== undefined) {
const fileid = String(lastUpload.response!.headers['oc-fileid']).split(/(oc|nc)/, 2)[0]!
logger.debug('Scrolling to last upload in current folder', { lastUpload })
const location: RawLocation = {
path: this.$route.path,
// Keep params but change file id
this.$router.push({
name: this.$route.name!,
params: {
// Keep params but change file id
...this.$route.params,
fileid: String(lastUpload.response!.headers['oc-fileid']),
fileid,
},
}
this.$router.push(location)
query: {
dir: this.$route.query.dir,
},
})
}
this.dragover = false