]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(files): focus sidebar tab on tab or file change
authorGrigorii K. Shartsev <me@shgk.me>
Tue, 6 Feb 2024 22:30:43 +0000 (23:30 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 8 Feb 2024 10:45:42 +0000 (10:45 +0000)
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
apps/files/src/views/Sidebar.vue

index d0c6b90b49d36fad2332e2f2f242749edddd9102..01cea14f8ebfdf529c2598ce3461f317256e31e5 100644 (file)
@@ -25,7 +25,6 @@
                ref="sidebar"
                v-bind="appSidebar"
                :force-menu="true"
-               tabindex="0"
                @close="close"
                @update:active="setActiveTab"
                @[defaultActionListener].stop.prevent="onDefaultAction"
@@ -470,6 +469,10 @@ export default {
                                throw new Error(`Invalid path '${path}'`)
                        }
 
+                       // Only focus the tab when the selected file/tab is changed in already opened sidebar
+                       // Focusing the sidebar on first file open is handled by NcAppSidebar
+                       const focusTabAfterLoad = !!this.Sidebar.file
+
                        // update current opened file
                        this.Sidebar.file = path
 
@@ -488,19 +491,23 @@ export default {
                                        view.setFileInfo(this.fileInfo)
                                })
 
-                               this.$nextTick(() => {
-                                       if (this.$refs.tabs) {
-                                               this.$refs.tabs.updateTabs()
-                                       }
-                                       this.setActiveTab(this.Sidebar.activeTab || this.tabs[0].id)
-                               })
+                               await this.$nextTick()
+
+                               this.setActiveTab(this.Sidebar.activeTab || this.tabs[0].id)
+
+                               this.loading = false
+
+                               await this.$nextTick()
+
+                               if (focusTabAfterLoad) {
+                                       this.$refs.sidebar.focusActiveTabContent()
+                               }
                        } catch (error) {
+                               this.loading = false
                                this.error = t('files', 'Error while loading the file data')
                                console.error('Error while loading the file data', error)
 
                                throw new Error(error)
-                       } finally {
-                               this.loading = false
                        }
                },