Skip to content

Commit f9a39bb

Browse files
committed
fix(focusTrap): allow to auto-resolve trap stack if was changed outside of controller
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent 2cfbff8 commit f9a39bb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/components/NcModal/NcModal.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ import Timer from '../../utils/Timer.js'
345345
import Close from 'vue-material-design-icons/Close.vue'
346346
import Pause from 'vue-material-design-icons/Pause.vue'
347347
import Play from 'vue-material-design-icons/Play.vue'
348-
import { useTrapStackControl } from '../../composables/useTrapStackControl.js'
349348
350349
export default {
351350
name: 'NcModal',
@@ -616,10 +615,6 @@ export default {
616615
},
617616
},
618617
619-
created() {
620-
useTrapStackControl(() => this.showModal)
621-
},
622-
623618
beforeMount() {
624619
window.addEventListener('keydown', this.handleKeydown)
625620
},

src/utils/focusTrap.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ export function createTrapStackController() {
4545
},
4646
/**
4747
* Unpause the paused focus trap stack
48+
* If the actual stack is different from the paused one, there were changes
49+
* outside of this controller, so we assume it's self-regulated and do not unpause.
4850
*/
4951
unpause() {
50-
for (const trap of pausedStack) {
51-
trap.unpause()
52+
if (pausedStack.length === getTrapStack().length) {
53+
for (const trap of pausedStack) {
54+
trap.unpause()
55+
}
5256
}
5357
pausedStack = []
5458
},

0 commit comments

Comments
 (0)