# Autofocus on input not working on ionic popup

**URL:** <https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603>\
**Category:** ionic-v1\
**Created:** [April 9, 2015, 11:25am UTC](https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603 "2015-04-09T11:25:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmigabreu](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@pmigabreu](https://forum.ionicframework.com/u/pmigabreu)\
**Post date:** [April 9, 2015, 11:25am UTC](https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603/1 "2015-04-09T11:25:07Z")

</div>

Hi Guys,

I’ve noticed the autofocus on the ionic popup stopped working for me… Don’t actually understand why but I’ve adapted a codepen and it still doesn’t autofocus on the input box

> **[Popup: Nightly](https://codepen.io/canihazcookienow/pen/ZYdQMp)**
>
> Various popups supported by Ionic Forked from \[Ionic\](http://codepen.io/ionic/)'s Pen \[Popup: Nightly\](http://codepen.io/ionic/pen/zkmhJ/)....

I’m running the last version (rc2)

---

<div class="post-metadata">

**Author:** ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://forum.ionicframework.com/u/jack2)\
**Post date:** [April 9, 2015, 9:25pm UTC](https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603/2 "2015-04-09T21:25:45Z")

</div>

Ionic doesn’t play well with autofocus.

Instead, use a directive like this:

```
.directive('focusMe', function($timeout) {
  return {
    link: function(scope, element, attrs) {
      $timeout(function() {
        element[0].focus(); 
      }, 150);
    }
  };
})
```

---

<div class="post-metadata">

**Author:** ![pmigabreu](https://avatars.discourse-cdn.com/v4/letter/p/8baadc/32.png) [@pmigabreu](https://forum.ionicframework.com/u/pmigabreu)\
**Post date:** [April 10, 2015, 9:44am UTC](https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603/3 "2015-04-10T09:44:48Z")

</div>

I’ve used something similiar but it doesn’t seem to work on iOS. Could it be related to the new iOS update ? I’m using iOS 8.3 and it was working before with the autofocus html tag on the input element.

---

<div class="post-metadata">

**Author:** ![mmoore99](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@mmoore99](https://forum.ionicframework.com/u/mmoore99)\
**Post date:** [April 10, 2015, 5:46pm UTC](https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603/4 "2015-04-10T17:46:02Z")

</div>

I am experiencing same problem after upgrading to iOS 8.3. Neither the ionic autofocus directive or the directive mentioned in @jack2’s post will work.

---

<div class="post-metadata">

**Author:** ![mhamel06](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhamel06/32/70008_2.png) [@mhamel06](https://forum.ionicframework.com/u/mhamel06)\
**Post date:** [April 21, 2015, 2:35pm UTC](https://forum.ionicframework.com/t/autofocus-on-input-not-working-on-ionic-popup/20603/5 "2015-04-21T14:35:37Z")

</div>

I am not using ionic with this project but started to have a similar issue after updating to iOS 8.3. This may also be related [https://github.com/meteoric/meteor-ionic/issues/97](https://github.com/meteoric/meteor-ionic/issues/97)

Going to try adding a timeout to see if it fixes the issue

```
elem.on('keyup', function(e){
                if(!isNaN(parseInt(String.fromCharCode(e.keyCode)))){
                    this.value = String.fromCharCode(e.keyCode);
                    if(this.nextElementSibling){
                        this.nextElementSibling.focus();
                    }
                }
            });
```
