Skip to content

Commit 7d1b719

Browse files
committed
fix(files): make sure we focus the parent actions submenu entry
Signed-off-by: John Molakvoæ <[email protected]>
1 parent 6594360 commit 7d1b719

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<!-- Default actions list-->
4646
<NcActionButton v-for="action in enabledMenuActions"
4747
:key="action.id"
48+
:ref="`action-${action.id}`"
4849
:class="{
4950
[`files-list__row-action-${action.id}`]: true,
5051
[`files-list__row-action--menu`]: isMenu(action.id)
@@ -64,7 +65,7 @@
6465
<!-- Submenu actions list-->
6566
<template v-if="openedSubmenu && enabledSubmenuActions[openedSubmenu?.id]">
6667
<!-- Back to top-level button -->
67-
<NcActionButton class="files-list__row-action-back" @click="openedSubmenu = null">
68+
<NcActionButton class="files-list__row-action-back" @click="onBackToMenuClick(openedSubmenu)">
6869
<template #icon>
6970
<ArrowLeftIcon />
7071
</template>
@@ -322,6 +323,21 @@ export default Vue.extend({
322323
return this.enabledSubmenuActions[id]?.length > 0
323324
},
324325
326+
async onBackToMenuClick(action: FileAction) {
327+
this.openedSubmenu = null
328+
// Wait for first render
329+
await this.$nextTick()
330+
331+
// Focus the previous menu action button
332+
this.$nextTick(() => {
333+
// Focus the action button
334+
const menuAction = this.$refs[`action-${action.id}`][0]
335+
if (menuAction) {
336+
menuAction.$el.querySelector('button')?.focus()
337+
}
338+
})
339+
},
340+
325341
t,
326342
},
327343
})

0 commit comments

Comments
 (0)