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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NcModal): Set return focus element on focus trap deactivation #5025

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
11 changes: 11 additions & 0 deletions src/components/NcModal/NcModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ export default {
type: Boolean,
default: undefined,
},

/**
* Set element to return focus to after focus trap deactivation
*
* @type {import('focus-trap').FocusTargetValueOrFalse}
*/
setReturnFocus: {
default: undefined,
type: [HTMLElement, SVGElement, String, Boolean],
},
},

emits: [
Expand Down Expand Up @@ -779,6 +789,7 @@ export default {
// Esc can be used without stop in content or additionalTrapElements where it should not deacxtivate modal's focus trap.
// Focus trap is deactivated on modal close anyway.
escapeDeactivates: false,
setReturnFocus: this.setReturnFocus,
}

// Init focus trap
Expand Down