diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index 06596f7b09..844b95d657 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -370,6 +370,14 @@ export default { type: String, default: 'body', }, + + /** + * Additional elements to add to the focus trap + */ + additionalTrapElements: { + type: Array, + default: () => [], + }, }, data() { @@ -416,6 +424,12 @@ export default { } } }, + additionalTrapElements(elements) { + if (this.focusTrap) { + const contentContainer = this.$refs.mask + this.focusTrap.updateContainerElements([contentContainer, ...elements]) + } + }, }, beforeMount() { @@ -582,7 +596,9 @@ export default { const contentContainer = this.$refs.mask // wait until all children are mounted and available in the DOM before focusTrap can be added this.$nextTick(() => { - this.focusTrap = createFocusTrap(contentContainer) + this.focusTrap = createFocusTrap(contentContainer, { + allowOutsideClick: true, + }) this.focusTrap.activate() }) },