Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NcModal): fix focus-trap fallback #4266

Merged
merged 1 commit into from Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -61,7 +61,7 @@
"emoji-mart-vue-fast": "^15.0.0",
"escape-html": "^1.0.3",
"floating-vue": "^1.0.0-beta.19",
"focus-trap": "^7.1.0",
"focus-trap": "^7.4.3",
"linkify-string": "^4.0.0",
"md5": "^2.3.0",
"node-polyfill-webpack-plugin": "^2.0.1",
Expand Down
12 changes: 8 additions & 4 deletions src/components/NcModal/NcModal.vue
Expand Up @@ -180,7 +180,8 @@ export default {
role="dialog"
aria-modal="true"
:aria-labelledby="'modal-name-' + randId"
:aria-describedby="'modal-description-' + randId">
:aria-describedby="'modal-description-' + randId"
tabindex="-1">
<!-- Header -->
<transition name="fade-visibility" appear>
<div class="modal-header">
Expand Down Expand Up @@ -707,11 +708,14 @@ export default {
// wait until all children are mounted and available in the DOM before focusTrap can be added
await this.$nextTick()

// Init focus trap
this.focusTrap = createFocusTrap(contentContainer, {
const options = {
allowOutsideClick: true,
fallbackFocus: contentContainer,
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved
trapStack: getTrapStack(),
})
}

// Init focus trap
this.focusTrap = createFocusTrap(contentContainer, options)
this.focusTrap.activate()
},
clearFocusTrap() {
Expand Down