# Ion-slide-box and input autofocus

**URL:** <https://forum.ionicframework.com/t/ion-slide-box-and-input-autofocus/44373>\
**Category:** ionic-v1\
**Created:** [February 22, 2016, 1:36am UTC](https://forum.ionicframework.com/t/ion-slide-box-and-input-autofocus/44373 "2016-02-22T01:36:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![warrenjoe92](https://avatars.discourse-cdn.com/v4/letter/w/a4c791/32.png) [@warrenjoe92](https://forum.ionicframework.com/u/warrenjoe92)\
**Post date:** [February 22, 2016, 1:36am UTC](https://forum.ionicframework.com/t/ion-slide-box-and-input-autofocus/44373/1 "2016-02-22T01:36:30Z")

</div>

I have been trying to use ion-slide-box to create a multi-staged form. I also wanted the input/select boxes to go automatically in focus when the user moves to a new slides. For that purpose, I used a custom autofocus directive.

The problem is that the autofocus directive messes up with the slide if it is triggered while the slide is still being animated.

I’ve created a CodePen to illustrate the problem here:

> **[ion-slide-box and autofocus bug](https://codepen.io/warrino/pen/WrqEoV)**
>
> ...

I’ve tried adding a timeout so that the autofocus directive waits for the animation to finish before being triggered. That worked, but only to an extent. The problem is that the bug still appears if the user decides to swipe back and forth quickly.

Does anyone have any idea on how to fix this?

Thank you.

---

<div class="post-metadata">

**Author:** ![warrenjoe92](https://avatars.discourse-cdn.com/v4/letter/w/a4c791/32.png) [@warrenjoe92](https://forum.ionicframework.com/u/warrenjoe92)\
**Post date:** [February 22, 2016, 4:18am UTC](https://forum.ionicframework.com/t/ion-slide-box-and-input-autofocus/44373/2 "2016-02-22T04:18:56Z")

</div>

In case anyone has the same problem, I found a quick and dirty fix by listening for transitions on ‘slider-slide’ before focusing on the input element:

> 

var target = document.getElementsByClassName(‘slider-slide’)[mySlide];  
target.addEventListener(‘transitionend’, focus);

This is far from perfect, but it works for now.

Here’s the CodePen if you want to have a look:

https://codepen.io/warrino/embed/preview/obroQZ?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=obroQZ
