Skip to content

Commit ab12076

Browse files
committed
fix(NcModal): use useTrapStackControl for pausing other focus traps
[skip ci] Signed-off-by: Maksim Sukharev <[email protected]>
1 parent 8030045 commit ab12076

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/components/NcModal/NcModal.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ import Timer from '../../utils/Timer.js'
351351
import Close from 'vue-material-design-icons/Close.vue'
352352
import Pause from 'vue-material-design-icons/Pause.vue'
353353
import Play from 'vue-material-design-icons/Play.vue'
354+
import { useTrapStackControl } from '../../composables/useTrapStackControl.js'
354355
355356
export default {
356357
name: 'NcModal',
@@ -574,7 +575,6 @@ export default {
574575
playing: false,
575576
slideshowTimeout: null,
576577
focusTrap: null,
577-
externalFocusTrapStack: [],
578578
randId: GenRandomId(),
579579
internalShow: true,
580580
}
@@ -657,6 +657,10 @@ export default {
657657
},
658658
},
659659
660+
created() {
661+
useTrapStackControl(() => this.showModal)
662+
},
663+
660664
beforeMount() {
661665
window.addEventListener('keydown', this.handleKeydown)
662666
},
@@ -864,11 +868,6 @@ export default {
864868
setReturnFocus: this.setReturnFocus,
865869
}
866870
867-
// Deactivate other focus traps to unlock modal elements
868-
this.externalFocusTrapStack = [...options.trapStack]
869-
for (const trap of this.externalFocusTrapStack) {
870-
trap.deactivate()
871-
}
872871
// Init focus trap
873872
this.focusTrap = createFocusTrap([contentContainer, ...this.additionalTrapElements], options)
874873
this.focusTrap.activate()
@@ -879,10 +878,6 @@ export default {
879878
}
880879
this.focusTrap?.deactivate()
881880
this.focusTrap = null
882-
for (const trap of this.externalFocusTrapStack) {
883-
trap.activate()
884-
}
885-
this.externalFocusTrapStack = []
886881
},
887882
888883
},

0 commit comments

Comments
 (0)