-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Conversation
There is no need to refocus on the auto-focused element since it is already Please use my pull request as I coded it. Thanks, -- Mike On Wed, May 28, 2014 at 11:08 AM, tmmueller [email protected]:
|
Unfortunately, at least in Chrome and according to MDN, autofocus gets applied only when the page is loaded. So if you open the modal more than once without reloading the page, you have to apply focus manually. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-autofocus |
@mlilli: Does this work in iOS? In Chrome, document.activeElement is the button I clicked to open the modal, so it doesn't make any difference.
|
Auto-focusing of a freshly-opened modal element causes any child elements with the autofocus attribute to loose focus. This is an issue on touch based devices which will show and then hide the onscreen keyboard. Attempts to refocus the autofocus element via JavaScript will not reopen the onscreen keyboard. Fixed by updated the focusing logic to only autofocus the modal element if the modal does not contain an autofocus element. Fixes angular-ui#1696 Closes angular-ui#1892 Closes angular-ui#2273
I don't think this issue is closed. The autofocus attribute only works the first time the modal is opened (in Chrome anyways) |
@sskirby Agreed. My pull request fixed that issue, but the accepted one did not. Maybe open a new issue? |
I'm running into this too – did this get fixed anywhere? |
Auto-focusing of a freshly-opened modal element causes any child elements with the autofocus attribute to loose focus. This is an issue on touch based devices which will show and then hide the onscreen keyboard. Attempts to refocus the autofocus element via JavaScript will not reopen the onscreen keyboard. Fixed by updated the focusing logic to only autofocus the modal element if the modal does not contain an autofocus element. Fixes angular-ui#1696 Closes angular-ui#1892 Closes angular-ui#2273
This is based on pull request #1892 from @mlilli. I rebased and squashed it as @pkozlowski-opensource requested. I also made it re-apply focus to the first autofocus element so that it works if you open the modal more than once.