Skip to content

Commit

Permalink
Merge pull request #3020 from nextcloud/bugfix/noid/focus-trap-modal-…
Browse files Browse the repository at this point in the history
…sidebar

Fix issues with focus trap on modal
  • Loading branch information
PVince81 authored Aug 12, 2022
2 parents 32a405e + 98098ff commit 44e5260
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/components/Modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ export default {
type: Boolean,
default: true,
},
/**
* Additional elements to add to the focus trap
*/
additionalTrapElements: {
type: Array,
default: () => [],
},
},
emits: [
Expand Down Expand Up @@ -505,6 +513,12 @@ export default {
}
}
},
additionalTrapElements(elements) {
if (this.focusTrap) {
const contentContainer = this.$refs.mask
this.focusTrap.updateContainerElements([contentContainer, ...elements])
}
},
},
beforeMount() {
Expand Down Expand Up @@ -661,7 +675,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()
})
},
Expand Down

0 comments on commit 44e5260

Please sign in to comment.