flowbite
flowbite copied to clipboard
Modal doesn't close when clicking background or hitting esc button
Describe the bug
Common expected modal functionality is to click outside of the modal to close the modal. Same goes for hitting the esc button.
To Reproduce Steps to reproduce the behavior:
- Go to: https://flowbite.com/docs/components/modal/
- Open any modal
- Click outside of the modal or hit the 'esc' button on the keyboard
Expected behavior I expect the modal to close on either of those. The modal doesn't. I have to click the close button instead.
Desktop:
- OS: OSX
- Browser: Chrome & Firefox
- Version: FF99
Smartphone:
- Device: iPhone
- OS: iOS 15.4.1
- Browser: Safari
Additional context I've replicated this on my local dev and on the Flowbite demo site.
+1
Hey @brianpurkiss,
Fair point. I'll look into this for the next update.
Regarding the keyboard action, we would like to incorproate for all of the components in the future, not just the modal.
+1 the same proble for me bro.
Hey @KinG-InFeT @brianpurkiss @Bolibick,
This issue has been addressed in the v1.5 update by closing the modal when clicking outside, but by also enabling the static backdrop (don't close when clicking outside) by using the data-modal-backdrop="static" data attribute on the modal element or by passing the backdrop: "static" or backdrop: dynamic option to a new Modal() class.
This is the commit:
https://github.com/themesberg/flowbite/commit/c111b3fc9ad9fa8ec7e9e1c9479aecf3e79d47e7
Additionally, the body scroll is now disabled when a modal is open.
Keyboard interaction coming in v1.5 as well.
PS: v1.5 is not yet launched, ETA 1-2 weeks.
Any update to this? It doesn't appear to be released with the 1.5 update, but really excited to use it once it drops
How to associate backdrop with particular modal? I think this is important because now when I inspect this will cause conflict when we have multiple modal (stacked) with different z-index settings on each backdrop.
This has been addressed and will be released in today's v1.5.4 update.