Merge pull request #41338 from nextcloud/fix/nested-actions-back-focus

fix(files): make sure we focus the parent actions submenu entry
pull/41015/head^2
John Molakvoæ 2024-01-31 18:06:15 +07:00 committed by GitHub
commit 02e9cd6ce5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 4 deletions

@ -45,6 +45,7 @@
<!-- Default actions list-->
<NcActionButton v-for="action in enabledMenuActions"
:key="action.id"
:ref="`action-${action.id}`"
:class="{
[`files-list__row-action-${action.id}`]: true,
[`files-list__row-action--menu`]: isMenu(action.id)
@ -64,7 +65,7 @@
<!-- Submenu actions list-->
<template v-if="openedSubmenu && enabledSubmenuActions[openedSubmenu?.id]">
<!-- Back to top-level button -->
<NcActionButton class="files-list__row-action-back" @click="openedSubmenu = null">
<NcActionButton class="files-list__row-action-back" @click="onBackToMenuClick(openedSubmenu)">
<template #icon>
<ArrowLeftIcon />
</template>
@ -322,6 +323,21 @@ export default Vue.extend({
return this.enabledSubmenuActions[id]?.length > 0
},
async onBackToMenuClick(action: FileAction) {
this.openedSubmenu = null
// Wait for first render
await this.$nextTick()
// Focus the previous menu action button
this.$nextTick(() => {
// Focus the action button
const menuAction = this.$refs[`action-${action.id}`][0]
if (menuAction) {
menuAction.$el.querySelector('button')?.focus()
}
})
},
t,
},
})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long