Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NcAppSidebar): manage focus only after transition has finished #5833

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/components/NcAppSidebar/NcAppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,6 @@ export default {
},

open() {
this.toggleFocusTrap()

this.checkToggleButtonContainerAvailability()
},
},
Expand All @@ -974,15 +972,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()
},

beforeDestroy() {
// 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 @@ -1061,6 +1050,13 @@ export default {
this.$emit('opening', element)
},
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 @@ -1085,6 +1081,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
Loading