How to blur/unfocus an ion-input?

hi!

is there a way to blur an ion-input field ? i use setFocus() to set the focus while swiping through slides. but on one slide there is a date picker instead of an ion-input field. The keyboard from the slide before stays open and if you type on it , it will change the field from the slide before.

Best solution would be to have something like setBlur() or removeFocus() but seems like there is nothing like that. does anyone know a workaround?

(using ionic-v4, hope this is the correct place to post)

What works for me in ionic 4 on keypress is this:

import { Renderer } from “@angular/core”;

keypressHandler($event) {
this.renderer.invokeElementMethod($event.target, “blur”);
}

So on sliding, you could use your ion-input native element reference and pass it to invokeElementMethod to blur it the same way. I hope it helps you out.

1 Like

May I know how to do this with Renderer2? Thanks.