-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Modal hidden event #16604
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
Comments
Hi @ray73864! You appear to have posted a live example (http://s.bootply.com/render/BzXT9pgtO7), which is always a good first step. However, according to Bootlint, your example has some Bootstrap usage errors, which might potentially be causing your issue:
You'll need to fix these errors and post a revised example before we can proceed further. (Please note that this is a fully automated comment.) |
Revised example using Bootstrap 3.3.4 same issue: |
Wrapping it in a setTimeout(function() {
$("#txtInput").focus();
}, 1); See: http://www.bootply.com/hsCP97LMhZ EDIT: apparently this also works with a time of 0. It seems when you apply |
Hrmm, kind of wanted to avoid using a setTimeout, but if that is the only way then so be it. |
Understandable. I'm not sure it's the only way, but it seems to work to fix the issue even if you set a 0ms delay. For that reason you shouldn't actually slow down the application in any noticeable manner because you aren't actually delaying it. |
For accessibility reasons, after hiding a modal, we refocus the button that was used to trigger the showing of the modal (see Line 331 in 6e8df2b
I will make a note that we should try to better accommodate cases like yours in Bootstrap v4. For v3, short of modifying modal.js , I think only somewhat-hacky solutions are available.
|
The |
Not sure what I'm doing wrong here, have managed to turn my issue into a simple example of what is going wrong at:
http://www.bootply.com/BzXT9pgtO7
Basically I'm trying to get it so that when a modal closes the hidden.bs.modal event sends the focus back to an input box on the page. I'm sure I've had this working before but cannot work out where I have gone wrong.
If I tell the hidden event to instead just put a value into the input box it shows up, I just can't get it to focus, I'm thinking it's a timing issue but then that's why I'm using the 'hidden' event as opposed to the 'hide' event.
The text was updated successfully, but these errors were encountered: