Merge pull request #57849 from nextcloud/backport/57842/stable33

[stable33] fix(files): do not reset active tab when re-opening
This commit is contained in:
Andy Scherzinger 2026-01-27 20:07:44 +01:00 committed by GitHub
commit 5d0f78f9a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 13 deletions

View file

@ -42,7 +42,7 @@ export const useSidebarStore = defineStore('sidebar', () => {
*/
function open(node: INode, tabId?: string) {
if (!(node && activeStore.activeFolder && activeStore.activeView)) {
logger.debug('Cannot open sidebar because the active folder or view is not set.', {
logger.debug('sidebar: cannot open sidebar because the active folder or view is not set.', {
node,
activeFolder: activeStore.activeFolder,
activeView: activeStore.activeView,
@ -51,6 +51,15 @@ export const useSidebarStore = defineStore('sidebar', () => {
throw new Error('Cannot open sidebar because the active folder or view is not set.')
}
if (isOpen.value && currentNode.value?.source === node.source) {
logger.debug('sidebar: already open for current node')
if (tabId) {
logger.debug('sidebar: already open for current node - switching tab', { tabId })
setActiveTab(tabId)
}
return
}
const newTabs = getTabs({
node,
folder: activeStore.activeFolder,
@ -58,12 +67,12 @@ export const useSidebarStore = defineStore('sidebar', () => {
})
if (tabId && !newTabs.find(({ id }) => id === tabId)) {
logger.warn(`Cannot open sidebar tab '${tabId}' because it is not available for the current context.`)
logger.warn(`sidebar: cannot open tab '${tabId}' because it is not available for the current context.`)
activeTab.value = newTabs[0]?.id
} else {
activeTab.value = tabId ?? newTabs[0]?.id
}
logger.debug(`Opening sidebar for ${node.displayname}`, { node })
logger.debug(`sidebar: opening for ${node.displayname}`, { node })
activeStore.activeNode = node
isOpen.value = true
}
@ -133,10 +142,10 @@ export const useSidebarStore = defineStore('sidebar', () => {
const filesStore = useFilesStore()
const node = filesStore.getNode(source)
if (node) {
logger.debug('Opening sidebar for node from Viewer.', { node })
logger.debug('sidebar: opening for node from Viewer.', { node })
open(node)
} else {
logger.error(`Cannot open sidebar for node '${source}' because it was not found in the current view.`)
logger.error(`sidebar: cannot open for node '${source}' because it was not found in the current view.`)
}
})
@ -148,7 +157,7 @@ export const useSidebarStore = defineStore('sidebar', () => {
window.OCP.Files.Router._router.afterEach((to, from) => {
if ((from.query && ('opendetails' in from.query))
&& (to.query && !('opendetails' in to.query))) {
logger.debug('Closing sidebar because "opendetails" query parameter was removed from URL.')
logger.debug('sidebar: closing because "opendetails" query parameter was removed from URL.')
close()
}
})
@ -160,7 +169,7 @@ export const useSidebarStore = defineStore('sidebar', () => {
const params = { ...(window.OCP?.Files?.Router?.params ?? {}) }
const query = { ...(window.OCP?.Files?.Router?.query ?? {}) }
logger.debug(`Sidebar current node changed: ${isOpen ? 'open' : 'closed'}`, { query, params, node: activeStore.activeNode })
logger.debug(`sidebar: current node changed: ${isOpen ? 'open' : 'closed'}`, { query, params, node: activeStore.activeNode })
if (!isOpen && ('opendetails' in query)) {
delete query.opendetails
window.OCP.Files.Router.goToRoute(

4
dist/files-main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long