openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.m.SearchField on iOS phone will not show keyboard when suggestions enabled

Open DeanDavis opened this issue 9 years ago • 7 comments

OpenUI5 version: 1.48.12

Browser/version (+device/version): Safari iOS 11

Any other tested browsers/devices(OK/FAIL): No other tested browser

Steps to reproduce the problem:

  1. Render a page with the tag and set enableSuggestions to true
  2. Display page on iOS Safari
  3. Try and type in search field. No keyboard

What is the expected result? Keyboard to allow text search

What happens instead? No keyboard displayed

Any other information? (attach screenshot if possible) The code in SearchFieldRenderer.js has this at line 103

if (oSF.getEnableSuggestions() && Device.system.phone) {
    // Always open a dialog on a phone if suggestions are on.
    // To avoid soft keyboard flickering, set the readonly attribute.
    rm.writeAttribute("readonly", "readonly");
}

It sets the HTML Input Tag readonly attribute to "readonly". iOS 11 on Safari will not pop up a keyboard if this is set.

DeanDavis avatar Oct 30 '17 18:10 DeanDavis

@DeanDavis please test if you see the keyboard with this example - https://openui5.hana.ondemand.com/#/sample/sap.m.sample.SearchFieldSuggestions/preview Note that the focus is on the suggestions when they are shown, and typing in the input pops the keyboard of the device. I tested with Chrome/Android 6 and Safari/iOS 11

stephania87 avatar Oct 30 '17 19:10 stephania87

Yes I did that. And I think I know the difference. The online example binds a model to the suggestionItems aggregation. So when you click into the field you immediately go into a dialog where all the suggestion items are displayed and the SearchField is re-rendered inside the dialog (a little UI trickery) and the keyboard will work because the new SearchField isn't readonly.

This is what the SearchField input tag looks like inside the dialog

<input type="search" autocomplete="off" autocorrect="off" id="__field0-I" class="sapMSFI" placeholder="Search">

But in my app I have nothing bound to suggestionItems initially. I'm using the 'suggest' event to call a function. In that function I see what the value is. If it is less than 3 characters then I do nothing, offer no suggestion items. Once I get to 3 characters or more then I search my array of possible suggestions for matches and create sap.m.SuggestionsItems and add them one at a time to the SearchField aggregation in code.

So, think, because I don't immediately go into the dialog, my search input element gets focus but I don't get a keyboard.

DeanDavis avatar Oct 30 '17 20:10 DeanDavis

@DeanDavis Please extend this example to illustrate the settings which reproduce the problem - https://jsbin.com/modopamiyu/edit?html,output Thanks

stephania87 avatar Nov 03 '17 17:11 stephania87

Use this link on an iPhone. https://output.jsbin.com/woqetev/ Demonstrates the problem.

The way I programmed it the dummy suggestion items would appear after entering 3 or more characters in the search bar. Works on browser and iPad but not iPhone.

DeanDavis avatar Nov 03 '17 18:11 DeanDavis

Hi, The way suggestions are not shown seems to be related to the problem, and it is reproducible on iPhone and Samsung mobile devices in my test. The case is forwarded to colleagues for further investigation with ticket #1780416030 Updates will be posted here as well.

stephania87 avatar Nov 21 '17 14:11 stephania87

Hi,

The sap.m.SearchField doesn't support minimum length of the entered text, before suggestions are opened. You cannot use a code like:

if (sv.length > 2) {
     this.oSF.suggest();
}

this.oSF.suggest(); must be always called in the 'suggest' event handler.

Only sap.m.Input support such scenarios with input.startSuggestion property.

Best, Teo

TeodorTaushanov avatar Nov 27 '17 11:11 TeodorTaushanov

There are many valid situations from a performance perspective when we would not like return to source until we have enough data to produce a meaningful list. It's disappointing that this isn't catered for. I assume the recommendation is to not use search field in these scenarios (even though we are searching) or to return an "keep on typing for more results" entry? Or just return 0 results but keep on suggesting?

wombling avatar Nov 18 '19 20:11 wombling