Skip to content

Commit

Permalink
Merge pull request #4678 from nextcloud-libraries/a11y/selected-actio…
Browse files Browse the repository at this point in the history
…ns-focus

fix: If a aria-selected button is present we focus on this one instead of the first entry
  • Loading branch information
susnux authored Oct 20, 2023
2 parents 32c7d04 + 1291055 commit bef86eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/NcActions/NcActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,11 @@ export default {
focusFirstAction(event) {
if (this.opened) {
this.preventIfEvent(event)
this.focusIndex = 0
// In case a button is considered aria-selected we will use this one as a initial focus
const firstSelectedIndex = [...this.$refs.menu.querySelectorAll(focusableSelector)].findIndex((button) => {
return button.parentElement.getAttribute('aria-selected')
})
this.focusIndex = firstSelectedIndex > -1 ? firstSelectedIndex : 0
this.focusAction()
}
},
Expand Down

0 comments on commit bef86eb

Please sign in to comment.