Ionic 2 - keep keyboard open when pressing submit button

the ionic keyboard opens when the input field / textarea becomes focused (?).

But when I hit the submit button, the keyboard disappears.

even when i call keyboard.show () method of keyboard plugin it first disappears and then reappears.

Is there a solution for this?

<textarea id="chat-text-area></textarea>

sendMessage() {
    if(window.cordova){
        this.keyboard.show()
    }
    if(this.form.valid){
        this.service.post(this.form.value).subscribe(res=>{
            document.getElementById('chat-text-area').focus()
        })
    }
}

      

+3


source to share


2 answers


add this to your submit button:

(mousedown)="$event.preventDefault(); sendMessage($event)"

      



Hope it helps :)

+1


source


Can you inject your logic into the hide event?



window.addEventListener('native.keyboardhide', keyboardHideHandler);

function keyboardHideHandler(e){
    if (something) // put your condition here
        e.preventDefault();
}

      

0


source







All Articles