cancel
Showing results for 
Search instead for 
Did you mean: 

Page refresh after switching focus from sap.m.Input

former_member393815
Discoverer
376

Hi there,

I have recently encountered a SAPUI5 behavior which I cannot tell if it is a bug or a feature :-).

I'm working on an app that is built with SAPUI5 v1.52, and, for the sake of simplicity, has 2 fields: a sap.m.SearchField and a sap.m.Input.

Upon selecting a suggestion of the SearchField, the Input is set to 1 and the focus is changed from the SearchField to the Input.

With the Input field in focus, the user has the possibility of modifying the Input and then switch back to the SearchField by pressing the Enter key. This is done by handling the submit event of the Input and moving the focus from the Input to the SearchField.

The strange part about this workflow is that upon switching the focus from the Input to the SearchField, the entire page is refreshed.

A short example can be found here: https://plnkr.co/plunk/dVGQPSh2MaAmF5Yw

After looking through the SAPUI5 docu, I stumbled upon the Side Effects topic which seems to be somewhat related to the use case I described.

So the question is: bug or feature :-)?

View Entire Topic
boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

Update: the issue is no longer reproducible due to the fix (commit: 491f3c6) available as of UI5 1.94.

Original answer: Definitely a bug. Here is an mcve: https://jsbin.com/qicayen/edit?js,output (Feel free to use that bin for reporting issue on GitHub). Not sure if UI5 could do anything about it though.

A quick fix would be to call the focus() asynchronously right after the last call stack has been processed:

setTimeout(() => this.byId("thatTargetControl").focus());
former_member393815
Discoverer

Hi Boghyon,

Thanks for the hint! It did solve my problem and I will also post a bug on github.

Have a good day!
Sergiu