sapui5

How to set focus on the search field when it is displayed?


I have a master-detail app (SplitContainer in HideMode)

In my master page I have a list item with a search input on the top. From any page if I open the master I have always the same master list page.

I would like that when I open the master the focus go to the search input. In this mode the user does not have to click on input to start write but is already there

Can I do the same when I open a SelectDialog? https://sdk.openui5.org/entity/sap.m.SelectDialog


Solution

  • I find the solution. thanks @cobeete In the onInit function of my master page I have written:

    sap.ui.getCore().byId("splitApp").attachAfterMasterOpen(function () {
                sap.ui.getCore().byId("UniversalMenu--searchItemFiled").focus();
    });
    

    where splitApp is my sap.m.SplitApp , UniversalMenu is the master page that include the search field searchItemFiled