Why focusing on input by default? ( android 4.3, Nightly build )

I have a screen with 3 input fields, whenever i navigate to it the second input field gets focus and raises the keyboard. I can’t figure out why, it doesn’t happen in the browser and there’s nothing special with the second input.

This is on Android 4.3 using the Nightly Build, on a browser (chrome) the field doesn’t get focus and works as expected.

1 Like

I have the same problem, Should be only by tap on textbox.

By chance, is the 2nd input field in the same location as where you last tapped to go to the new view? What I’m getting at is whether the previous tap is causing the focus due to some delay?

Questions :

  • Can you try this on Beta 2 with the same code?
  • Can you post a CodePen sample of the exact code? Someone can then try to put it in a local project for testing.

It is indeed at the same location as the previous touch. I didn’t even realize that! I’ll try to put together a codepen at some point today.

I’m having the same issue intermittently (on ios in my case) and I think you’ve figured it out. If the tap is in the same position as the input on the next screen, the input gets focused incorrectly.

It’s happening both with tabbed views and modals.

It must have something to do with timing. If i put in an alert in my controller that handles the destination page then the autofocus doesn’t happen. Maybe this gives the touch time to be “over” before the template is brought up. If I remember right Ionic does something with x and y coordinates to get around the browser 300ms delay in touch vs click. Maybe it’s something in that code.

It’s going to be really hard for the devs to come up with a fix for something they might not be able to reproduce. If you can post a CodePen sample of your code and then open an Issue that would be best. Admittedly, the CodePen won’t work right on the phone, but they can easily put it in a local demo app for testing on device.

ok here’s a codepen, hopefully it will trigger the issue when running on a local Android.

It happens 100% of the time on my Samsung Note2 running Android 4.3 and the nightly build of ionic

I’ve been struggling with this same bug for a while now, then I saw this post. Experiencing the same issue on all iOS versions.

What’s the status on this?

I just did a little hack/workaround in my app that suppresses this issue without really affecting the user experience. Basically the approach is to cover the inputs with an invisible div so that the input focus isn’t transferred and then hide this invisible div after half a second or so, before user would actually tap anything. Hacky, but works well enough for my app so far.

Here’s how it works:

  1. Add html like this somewhere in your view:

  2. Some css like this:

    .ghostclick-preventer { background-color: none; width: 100%; height: 100%; display: block; position: absolute; top: 0px; left: 0px; z-index: 3; }

  3. And lastly, in your controller add something like this:

    $timeout(function() {
    $scope.preventGhostClicks = false;
    }, 500);

That fixed the issue for me too. Thanks!

I am also struggling with this issue… Would be great to have a work around. For now I’ll use udi’s suggestion

I am having this issue as well in iOS using the newest beta. Is there a fix for this available.