From 7ffec75c845363e81f2bbcb1472897c67ce87d1d Mon Sep 17 00:00:00 2001
From: wazeerc <58399263+wazeerc@users.noreply.github.com>
Date: Sat, 27 Sep 2025 15:53:53 +0400
Subject: [PATCH] fix: close modal on esc keypress even when focusTrap is
enabled
---
docs/components/modal.md | 2 +-
src/components/FwbModal/FwbModal.vue | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/components/modal.md b/docs/components/modal.md
index f9bc64ad..4fe8e9dd 100644
--- a/docs/components/modal.md
+++ b/docs/components/modal.md
@@ -161,7 +161,7 @@ import { FwbModal } from 'flowbite-vue'
## Focus Trap
-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.
+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.
```vue
diff --git a/src/components/FwbModal/FwbModal.vue b/src/components/FwbModal/FwbModal.vue
index 2c6a3ffa..8cd0423e 100644
--- a/src/components/FwbModal/FwbModal.vue
+++ b/src/components/FwbModal/FwbModal.vue
@@ -128,6 +128,7 @@ const modalRef: Ref = ref(null)
const { activate, deactivate } = useFocusTrap(modalRef, {
immediate: false,
initialFocus: () => modalRef.value?.querySelector('button[aria-label="close"]') || modalRef.value,
+ escapeDeactivates: false,
})
onMounted(async () => {