Skip to content

Commit

Permalink
Merge pull request #5840 from nextcloud-libraries/backport/5833/next
Browse files Browse the repository at this point in the history
[next] fix(NcAppSidebar): manage focus only after transition has finished
  • Loading branch information
ShGKme authored Jul 22, 2024
2 parents 17c3098 + d642138 commit 368144e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/components/NcAppSidebar/NcAppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,6 @@ export default {
},
open() {
this.toggleFocusTrap()
this.checkToggleButtonContainerAvailability()
},
},
Expand All @@ -971,15 +969,6 @@ export default {
this.checkToggleButtonContainerAvailability()
},
mounted() {
// Focus sidebar on open only if it was opened by a user interaction
if (this.elementToReturnFocus) {
this.focus()
}
this.toggleFocusTrap()
},
beforeUnmount() {
// Make sure that the 'closed' event is dispatched even if this element is destroyed before the 'after-leave' event is received.
this.$emit('closed')
Expand Down Expand Up @@ -1051,6 +1040,13 @@ export default {
},
onAfterEnter(element) {
// Focus sidebar on open only if it was opened by a user interaction
if (this.elementToReturnFocus) {
this.focus()
}
this.toggleFocusTrap()
/**
* The sidebar is opened and the transition is complete
*
Expand All @@ -1066,6 +1062,8 @@ export default {
*/
this.$emit('closed', element)
this.toggleFocusTrap()
// Return focus to the element that had focus before the sidebar was opened
this.elementToReturnFocus?.focus({ focusVisible: true })
this.elementToReturnFocus = null
Expand Down

0 comments on commit 368144e

Please sign in to comment.