SearchBar - onTap event not working


#1

Hi,

I’m trying to a tap event from a SearchBar, it does work well on iOS but no event is fired on Android.

Here is my code:

XML:

<SearchBar (tap)="toggle()" #sb row="0" hint="Search" (loaded)="onSearchBarLoaded($event)" (clear)="onClear()"></SearchBar>

I also tried this:

<StackLayout (tap)="toggle()">
     <SearchBar #sb row="0" hint="Search" (loaded)="onSearchBarLoaded($event)" (clear)="onClear()"></SearchBar>
</StackLayout>

Component:

     constructor() {
        this.focused = false;
    }
    toggle() {
        console.log('tapped');
        this.focused = !this.focused;
    }

    onSearchBarLoaded(event) {
        if (event.object.android) {
            setTimeout(() => {
                event.object.dismissSoftInput();
                event.object.android.clearFocus();
            }, 0);
        }
    }

    onClear () {
        console.log('onClear');
    }