-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape key is totally supressed in modal when data-bs-keyboard is false #40801
Comments
I believe this line of code is the problem, it appears to be preventing the escape key from doing anything. I feel like a better solution would be to not prevent default escape key behavior, or at least add an option to opt out of it preventing the use of the escape key within a modal. https://github.com/twbs/bootstrap/blob/main/js/src/modal.js#L266 Edit: Also important to note is if you change to listen for keydown event the escape key is not supressed on elements within the modal, but keyup on escape is completely intercepted. |
Thanks for reporting an issue @raysuelzer I quickly created an example replicating your modal setup, adding a basic Bootstrap dropdown example along with a custom typeahead, which you can check out here: CodePen Example.
Based on your description:
I'm not entirely sure I see the difference between our setups. Could you clarify the specific scenario where the escape key isn't behaving as expected in your case? It's possible I may have misunderstood the issue, so any additional details would help :) |
As the issue was labeled with |
Prerequisites
Describe the issue
I have a typeahead which appears within a modal. Pressing the escape key should close the typeahead results. However, it appears bootstrap is completely supressing the escape key event so any bindings to the escape key used within a modal are never triggered.
You can see in the console.log that all keys except for escape key are correctly picked up by the event listener.
Reduced test cases
Minimal reproduction: https://codepen.io/raysuelzer/pen/mdZvzKm
What operating system(s) are you seeing the problem on?
Windows, macOS, Linux
What browser(s) are you seeing the problem on?
Chrome, Safari, Firefox, Microsoft Edge, Opera
What version of Bootstrap are you using?
v5.3.3
The text was updated successfully, but these errors were encountered: