-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Adding focus to modal-window in modalWindow directive new in 0.10.0 #1696
Comments
Could you provide a minimal reproducible scenario in Plunker please? |
@dougmcclurg ok, I see. This one is tricky as we need to focus the modal window to get the focus away from a link / button that actually trigger modal opening. Need to check what the original bootstrap is doing in this case (and would appreciate you digging into this as well!) |
👍 to this issue: I was using 'autofocus' in some of the elements on my modals and this no longer works since we upgraded to 0.9.0, unless we re-assert focus after some hefty delay. It would be nice to determine exactly what behavior happened after the modal appears, rather than just doing Traditional bootstrap modals allow you to install behavior on a 'shown' event when you know the to-be-focused elements are rendered and ready for focus. I'm not sure if this is best in Angular-land, where it's probably better for the to-be-focused element to declare its desires the template via the For now, I've implemented the following workaround
which re-asserts autofocus after |
Line 94 modal.js does the focus that prevents/overrides my focus. Can we get a hook after that please? For the moment I'll just "patch" the file with a line after your focus so it does |
👍 to this issue |
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
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
with the latest stable versions |
As of 2.2+, autofocus stopped working. 2.1.4 is working OK. |
For me, autofocus only did work for the very first time I opened the modal, all next ones the focus did not work. I ended up implementing this and it worked fine. |
I recently upgraded my modal directive from 0.6.0 to 0.10.0.
My usage involves focusing an input inside the modal on launch which i was previously able to do in 0.6.0.
The addition of the below code in the modal directive in 0.10.0 does not allow me to focus on my input.
// focus a freshly-opened modal
element[0].focus();
The only things i can do to get around this are particularly messy and i was wondering if adding focus to the modal-window could be a configurable option?
If anybody has a clean way of solving i'd love to hear about it.
Thanks for all your killer work.
The text was updated successfully, but these errors were encountered: