Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71530

Ionic2 select text in ion-searchbar

$
0
0

@carlosadrian wrote:

In an ion-input focus event we can select all the text like this

< ion-input (focus)="selectAll($event)" ></ ion-input >

But in an ion-searchbar it does not work:

< ion-searchbar (focus)="selectAll($event)"></ ion-searchbar>

The selectAll() code would be:

public selectAll(event): void {
event.target.select();
}

I have seen in ionic's Github that the input component returns a FocusEvent:

inputFocused(event) {
this.focus.emit(event);
}

On the other hand the ion-searchbar returns a searchbar (this):

inputFocused() {
this.focus.emit(this);

this.isFocused = true;
this.shouldLeftAlign = true;
this.setElementLeft();
}

Why does it not return a FocusEvent too? How can we select all the text in an ion-searchbar when it is focused?

Thank you

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71530

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>