Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/NcDialog/NcDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export default {
</docs>

<script setup lang="ts">
import type { FocusTargetOrFalse } from 'focus-trap'
import type { Slot } from 'vue'
import type { ComponentProps, VueClassType } from '../../utils/VueTypes.ts'

Expand All @@ -237,6 +238,12 @@ const props = withDefaults(defineProps<{
/** Additional elements to add to the focus trap */
additionalTrapElements?: Array<string | HTMLElement>

/** Set element to return focus to after focus trap deactivation */
setReturnFocus?: FocusTargetOrFalse

/** Specify an element to receive initial focus after focus trap activation */
initialFocus?: FocusTargetOrFalse

/**
* The element where to mount the dialog, if `null` is passed the dialog is mounted in place.
*/
Expand Down Expand Up @@ -490,6 +497,8 @@ const modalProps = computed(() => ({
outTransition: props.outTransition,
closeOnClickOutside: props.closeOnClickOutside,
additionalTrapElements: props.additionalTrapElements,
setReturnFocus: props.setReturnFocus,
initialFocus: props.initialFocus,
}))
</script>

Expand Down
11 changes: 11 additions & 0 deletions src/components/NcModal/NcModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,16 @@ export default {
default: undefined,
type: [Boolean, HTMLElement, SVGElement, String],
},

/**
* Specify an element to receive initial focus after focus trap activation
*
* @type {import('focus-trap').FocusTargetValueOrFalse}
*/
initialFocus: {
default: undefined,
type: [Boolean, HTMLElement, SVGElement, String],
},
},

emits: [
Expand Down Expand Up @@ -863,6 +873,7 @@ export default {
// Focus trap is deactivated on modal close anyway.
escapeDeactivates: false,
setReturnFocus: this.setReturnFocus,
initialFocus: this.initialFocus,
}

// Init focus trap
Expand Down
Loading