Skip to content

Commit

Permalink
fix(NcAppSidebar): manage focus only after transition has finished
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Jul 20, 2024
1 parent 17c3098 commit d642138
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 d642138

Please sign in to comment.