Skip to content

Commit 103e3a5

Browse files
authored
Merge pull request #408 from wazeerc/fix/a11y/modal-esc-focustrap
Close modal on esc keypress even when focusTrap is enabled
2 parents 16fb867 + 7ffec75 commit 103e3a5

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

docs/components/modal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ import { FwbModal } from 'flowbite-vue'
161161

162162
## Focus Trap
163163

164-
You can enable focus trapping by setting the `focus-trap` prop to `true`. This keeps the focus within the modal, preventing users from tabbing to elements outside of it, which improves accessibility.
164+
You can enable focus trapping by setting the `focus-trap` prop to `true`. This keeps the focus within the modal, preventing users from tabbing to elements outside of it, which improves accessibility. esc key will still close the modal.
165165

166166
<fwb-modal-example-focus-trap />
167167
```vue

src/components/FwbModal/FwbModal.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const modalRef: Ref<HTMLElement | null> = ref(null)
128128
const { activate, deactivate } = useFocusTrap(modalRef, {
129129
immediate: false,
130130
initialFocus: () => modalRef.value?.querySelector('button[aria-label="close"]') || modalRef.value,
131+
escapeDeactivates: false,
131132
})
132133
133134
onMounted(async () => {

0 commit comments

Comments
 (0)