Skip to content

Commit bd45e71

Browse files
authored
Merge pull request #43448 from nextcloud/backport/42444/stable28
[stable28] fix(files): move focus to sidebar on open
2 parents 32fbcd3 + 33c7f9b commit bd45e71

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
<NcActions ref="actionsMenu"
3636
:boundaries-element="getBoundariesElement"
3737
:container="getBoundariesElement"
38-
:disabled="isLoading || loading !== ''"
3938
:force-name="true"
4039
type="tertiary"
4140
:force-menu="enabledInlineActions.length === 0 /* forceMenu only if no inline actions */"
@@ -272,6 +271,11 @@ export default Vue.extend({
272271
},
273272
274273
async onActionClick(action, isSubmenu = false) {
274+
// Skip click on loading
275+
if (this.isLoading || this.loading !== '') {
276+
return
277+
}
278+
275279
// If the action is a submenu, we open it
276280
if (this.enabledSubmenuActions[action.id]) {
277281
this.openedSubmenu = action

apps/files/src/views/Sidebar.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
ref="sidebar"
2626
v-bind="appSidebar"
2727
:force-menu="true"
28-
tabindex="0"
2928
@close="close"
3029
@update:active="setActiveTab"
3130
@[defaultActionListener].stop.prevent="onDefaultAction"
@@ -470,6 +469,10 @@ export default {
470469
throw new Error(`Invalid path '${path}'`)
471470
}
472471
472+
// Only focus the tab when the selected file/tab is changed in already opened sidebar
473+
// Focusing the sidebar on first file open is handled by NcAppSidebar
474+
const focusTabAfterLoad = !!this.Sidebar.file
475+
473476
// update current opened file
474477
this.Sidebar.file = path
475478
@@ -488,19 +491,23 @@ export default {
488491
view.setFileInfo(this.fileInfo)
489492
})
490493
491-
this.$nextTick(() => {
492-
if (this.$refs.tabs) {
493-
this.$refs.tabs.updateTabs()
494-
}
495-
this.setActiveTab(this.Sidebar.activeTab || this.tabs[0].id)
496-
})
494+
await this.$nextTick()
495+
496+
this.setActiveTab(this.Sidebar.activeTab || this.tabs[0].id)
497+
498+
this.loading = false
499+
500+
await this.$nextTick()
501+
502+
if (focusTabAfterLoad) {
503+
this.$refs.sidebar.focusActiveTabContent()
504+
}
497505
} catch (error) {
506+
this.loading = false
498507
this.error = t('files', 'Error while loading the file data')
499508
console.error('Error while loading the file data', error)
500509
501510
throw new Error(error)
502-
} finally {
503-
this.loading = false
504511
}
505512
},
506513

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-sidebar.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-sidebar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)