Autofocus corrects the second time that the modal is open

Autofocus corrects the second time that the modal is open. This fixes the issue #2802.
Example: http://plnkr.co/4sX9F3hObN0YmTU15m06