Skip to content

Commit 962c703

Browse files
artongebackportbot[bot]
authored andcommitted
feat: Reset route if neither the Viewer of the Sidebar is open
When the viewer or the sidebar is opened, we add the fileid to the route. When both of them are closed, we do not remove the fileid from the route. This means that, upon reload, the sidebar will be opened even though it was closed previously. This PR ensure that the fileid is removed from the route when both the Sidebar and the Viewer are closed. Signed-off-by: Louis Chemineau <louis@chmn.me> [skip ci]
1 parent 124b565 commit 962c703

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

apps/files/src/components/FilesListVirtual.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ export default defineComponent({
231231
beforeDestroy() {
232232
const mainContent = window.document.querySelector('main.app-content') as HTMLElement
233233
mainContent.removeEventListener('dragover', this.onDragOver)
234+
235+
unsubscribe('files:sidebar:closed', this.unselectFile)
234236
},
235237
236238
methods: {
@@ -258,15 +260,22 @@ export default defineComponent({
258260
}
259261
},
260262
263+
unselectFile() {
264+
// If the Sidebar is closed and if openFile is false, remove the file id from the URL
265+
if (!this.openFile && OCA.Files.Sidebar.file === '') {
266+
window.OCP.Files.Router.goToRoute(
267+
null,
268+
{ ...this.$route.params, fileid: String(this.currentFolder.fileid ?? '') },
269+
this.$route.query,
270+
)
271+
}
272+
},
273+
261274
/**
262275
* Handle opening a file (e.g. by ?openfile=true)
263276
* @param fileId File to open
264277
*/
265278
handleOpenFile(fileId: number|null) {
266-
if (!this.openFile) {
267-
return
268-
}
269-
270279
if (fileId === null || this.openFileId === fileId) {
271280
return
272281
}
@@ -289,7 +298,7 @@ export default defineComponent({
289298
.at(0)
290299
// Some file types do not have a default action (e.g. they can only be downloaded)
291300
// So if there is an enabled default action, so execute it
292-
defaultAction?.exec(node, this.currentView, this.currentFolder.path)
301+
defaultAction?.exec(node, this.currentView, this.currentFolderpath)
293302
},
294303
295304
onDragOver(event: DragEvent) {

0 commit comments

Comments
 (0)