Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@ export default defineComponent({

openSidebarForFile(fileId) {
// Open the sidebar for the given URL fileid
// iif we just loaded the app.
const node = this.nodes.find((n) => n.fileid === fileId) as INode
// if we just loaded the app.
const node = (this.currentFolder?.fileid === fileId
? this.currentFolder
: this.nodes.find((n) => n.fileid === fileId)) as INode | undefined
Comment on lines +316 to +319
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this is enough to fix the issue

if (node && this.sidebar.available) {
logger.debug('Opening sidebar on file ' + node.path, { node })
this.sidebar.open(node)
Expand Down
38 changes: 25 additions & 13 deletions apps/files/src/store/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const useSidebarStore = defineStore('sidebar', () => {
logger.debug('sidebar: already open for current node - switching tab', { tabId })
setActiveTab(tabId)
}
updateOpenRoute(node)
Copy link
Copy Markdown
Contributor

@susnux susnux May 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are those changes needed? The fileid should already be handled by the active store?
So the watcher here should properly trigger the opendetails query?

return
}

Expand All @@ -75,6 +76,7 @@ export const useSidebarStore = defineStore('sidebar', () => {
logger.debug(`sidebar: opening for ${node.displayname}`, { node })
activeStore.activeNode = node
isOpen.value = true
updateOpenRoute(node)
}

/**
Expand Down Expand Up @@ -124,6 +126,28 @@ export const useSidebarStore = defineStore('sidebar', () => {
activeTab.value = tabId
}

function updateOpenRoute(node: INode) {
const params = { ...(window.OCP?.Files?.Router?.params ?? {}) }
const query = { ...(window.OCP?.Files?.Router?.query ?? {}) }
const nextParams = typeof node.fileid === 'number'
? { ...params, fileid: String(node.fileid) }
: params

if (('opendetails' in query) && nextParams.fileid === params.fileid) {
return
}

window.OCP.Files.Router.goToRoute(
null,
nextParams,
{
...query,
opendetails: 'true',
},
true,
)
}

// update the current node if updated
subscribe('files:node:updated', (node: INode) => {
if (node.source === currentNode.value?.source) {
Expand Down Expand Up @@ -164,7 +188,7 @@ export const useSidebarStore = defineStore('sidebar', () => {
}
})

// watch open state and update URL query parameters
// watch close state and update URL query parameters
watch(isOpen, (isOpen) => {
const params = { ...(window.OCP?.Files?.Router?.params ?? {}) }
const query = { ...(window.OCP?.Files?.Router?.query ?? {}) }
Expand All @@ -179,18 +203,6 @@ export const useSidebarStore = defineStore('sidebar', () => {
true,
)
}

if (isOpen && !('opendetails' in query)) {
window.OCP.Files.Router.goToRoute(
null,
params,
{
...query,
opendetails: 'true',
},
true,
)
}
})

return {
Expand Down
Loading