angular-ui/ui-select — pull request #47 by mattiash (2014-04-04 20:10:20+00:00)
Title: Retain keyboard focus after closing the dropdown.

Fixes #46.

The fix does two things. First, it actively sets focus back to the button after closing the dropdown. To do this, it uses $timeout with a zero timeout value to give angular time to show the button before changing focus to it. This is the same as was done previously when showing the dropdown.

There is however a second problem: bootstrap defines a transition for form_control. This means that it takes some time before the button is shown. This means that when the timeout fires and focus() is called, the button is still hidden and thus cannot be focused.

To work around the second problem, we can either use a slightly longer timeout (a few 100ms), or we can disable the transitions. I have chosen to disable the transitions, since the timeout feels "ugly". This is done in the patch to select.css.