Tip #11 Auto select input text on focus

Sometimes you simply don't need a directive, plugin or custom component.

Do you want to select the input content when clicked, like github does with clone url?

Just add this code to your input:

<input @focus="$event.target.select()">

That's it! But remember, if your input is inside a component, you have to add .native to the event, like this:

<my-component @focus.native="$event.target.select()"></my-component>
Show your support

Clapping shows how much you appreciated Marcos Neves’s story.