ionic 2 & 3 input focus

Ionic Version 3.19.0

At config.xml add

<preference name=”KeyboardDisplayRequiresUserAction” value=”false” />

For example we going to open a modal and then focus input inside modal.

let commentModal = this.modalCtrl.create(‘CommentPage’,{},{cssClass: ‘comment-page’ });
keyboardClose: false

there is commentModal.present, when modal present we going to let keyboard stay open, so we set keyboardClose:false;

on html

add autofocus attribute on input

<input type=”text” autofocus />

🙂 that’s it.

Leave a Reply

Your email address will not be published. Required fields are marked *