Add this function inside the class of your .ts file (best before the constructor):
ionViewDidLoad(){ document.getElementsByClassName('searchbar-input')[0].setAttribute("onFocus", "openSearchModal()"); }
Description
The ion element ion-searchbar creates several children, one of which, of course, is the input element, which has the class searchbarElement .
First, ask to get all these elements with this class name. This returns an array of such elements, in the first position of which, at index = 0, is the <input> field, whose functionality we want to change.
Then we programmatically set the onFocus attribute, which is called when the element receives focus (for example, when pressed). This essentially does it as follows:
<input class="searchbar-input" onFocus="openSearchModal()">
So, at the end, when the user clicks on the search box, the modal is called.
Then we wrap it all up inside ionViewDidLoad() , which provides a lifecycle cache loop binding that we can use to run the code right after the view has loaded.
source share