Skip to content

Commit

Permalink
fix(NcActions): intercept into current focus trap stack
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Jan 25, 2024
1 parent 20577bc commit 234bec9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/components/NcActions/NcActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ export default {
isSemanticMenu: false,
isSemanticNavigation: false,
isSemanticPopoverLike: false,
externalFocusTrapStack: [],
}
},
Expand All @@ -1016,9 +1017,38 @@ export default {
this.opened = state
},
opened() {
this.intersectIntoCurrentFocusTrapStack()
},
},
methods: {
/**
* If the component has its own focus trap, then it is managed by global trap stack by focus-trap.
*
* But if the component has no focus trap and used inside another focus trap - there is an issue.
* By default popover content is rendered in body or other container, which is likely outside the current focus trap containers.
* We need pause the focus-trap for opening popover and then unpause it after closing.
*/
intersectIntoCurrentFocusTrapStack() {
if (this.focusTrap) {
return
}
if (this.internalShown) {
this.externalFocusTrapStack = [...getTrapStack()]

Check failure on line 1040 in src/components/NcActions/NcActions.vue

View workflow job for this annotation

GitHub Actions / eslint

'getTrapStack' is not defined
for (const trap of this.externalFocusTrapStack) {
trap.pause()
}
} else {
for (const trap of this.externalFocusTrapStack) {
trap.unpause()
}
this.externalFocusTrapStack = []
}
},
/**
* Do we have exactly one Action and
* is it allowed as a standalone element?
Expand Down

0 comments on commit 234bec9

Please sign in to comment.