Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

focusFirstFocusableElement misses elements in modals including directives #6292

Open
viveleroi opened this issue Oct 14, 2016 · 2 comments
Open

Comments

@viveleroi
Copy link

viveleroi commented Oct 14, 2016

Bug description:

Recently-added code to auto focus the first focusable element in a modal does not work correctly when the modal includes other directives.

For example, we have a search-field directive which includes a text input and a button. This directive is used inside the modal-body. Yet when this code is triggered:

$modalStack.focusFirstFocusableElement($modalStack.loadFocusElementList(modalWindow));

The array from loadFocusElementList does not include our search field input. In our case, wrapping the above line in a $timeout solves our issue, because our directive has compiled correctly by the next event cycle.

Link to minimally-working plunker that reproduces the issue:

https://plnkr.co/edit/9LQxnCyQIQuJLvfvTjkw?p=preview

Version of Angular, UIBS, and Bootstrap

Angular: 1.5.8

UIBS: 2.2.0

Bootstrap: 3.3.7

@viveleroi viveleroi changed the title focusFirstFocusableElement fails in modals including directives focusFirstFocusableElement misses elements in modals including directives Oct 14, 2016
@wesleycho
Copy link
Contributor

I would be fine wrapping that call in a $timeout.

PR is welcome for this - be sure to modify the relevant tests to flush the timeout if necessary for this change.

@dgsmith2
Copy link

dgsmith2 commented Jan 5, 2017

It appears this was fixed in #6295

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants