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 18, 2024
1 parent 0febe32 commit 4c45bf0
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 @@ -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()
}

Check failure on line 1057 in src/components/NcAppSidebar/NcAppSidebar.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Trailing spaces not allowed
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

0 comments on commit 4c45bf0

Please sign in to comment.