-
-
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
HTML5 <input> autofocus attribute inside modals #12525
Comments
That's because the modal does not get injected into the DOM dynamically but rather exists the whole time (unless you use the |
Of course Bootstrap could implement this by just searching the modal for an input with the |
@hnrch02 tested the linked-to solution in Chrome and it works great. But doesn't seem to work on iPad. |
Triggering focus on iOS seems tricky. |
It does seem to be! |
At least about html5-autofocus I know that most mobile browser (besides android-firefox) ignore the autofocus attribute. It appears to be a good idea regarding the usability. In most cases you don't want to cover half the screen / web page with the virtual keyboard in the moment you load the page. |
@twbs/team What are folks' thoughts on this? |
i dont think we should implement this in core for now. People should be able to easily shim this with a global listener (untested): $(document).on('shown.bs.modal', function (e) {
$(e.target, '[autofocus]').focus()
})
It's also nasty because it fires the virtual keyboard which introduces a whole bunch of sadness and confusion to a user (especially if they are just triggering a modal). |
it's also one of those things, which might be worth visiting – depending if it comes up a lot – because it's pretty easy to add |
@fat shouldn't that be: $(document).on('shown.bs.modal', function (e) {
$('[autofocus]', e.target).focus();
}); |
Focus doesn't seem to happen when using the HTML5 autofocus attribute on a text input when the text input is inside a modal
Tested in Chrome 32.0.1700.76 m using Bootstrap v3.1
The text was updated successfully, but these errors were encountered: