Searchbar setFocus() doesn't open keyboard


#1

I managed to set focus on a Searchbar when a button is clicked, but keyboard won’t open even after setting KeyboardDisplayRequiresUserAction to false in config.xml.

I’m testing it in an Android 4.4.

The code in template:

<ion-searchbar #searchbar></ion-searchbar>

In the class (striped out unrelated lines):

@ViewChild('searchbar') searchbar: Searchbar;

public toggleSearchBar(){
  let timeoutID = setTimeout(() => {
    this.searchbar.setFocus();
    clearTimeout(timeoutID);
  }, 200)
}

In config:

<preference name="KeyboardDisplayRequiresUserAction" value="false"/>

What’s happening here? :confused:


#2

I am having the same issue. Have you got any advances on this?


#3

Nothing at all. Guess I’ll have to get rid of the Searchbar and use an input instead.

I’ll let you know as soon as I get it to work.


#4

Thanks, I have been trying also, and I found several forums with the same example that is supposed to work and I haven’t had luck :frowning:


#5

Maybe you’re testing in an Android 4.4 just as I am.

There’s no such thing as luck. :disappointed_relieved: