ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Blur event on ion-input is not fired

Open xkjyeah opened this issue 10 years ago • 11 comments

<ion-input type="text" (blur)="eventHandler()"> does not fire the eventHandler on blur.

Blur and other events should be bubbled to the parent container to allow for more complex interactions

xkjyeah avatar Feb 17 '16 17:02 xkjyeah

Is this in Ionic1 or Ionic2?

adamdbradley avatar Feb 18 '16 15:02 adamdbradley

Ionic2. On Feb 18, 2016 23:09, "Adam Bradley" [email protected] wrote:

Is this in Ionic1 or Ionic2?

— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/5487#issuecomment-185760995.

xkjyeah avatar Feb 18 '16 23:02 xkjyeah

Here is a current work around for "blur".

Use "focusout" or "mouseleave". Those are both working.

prolink007 avatar Feb 26 '16 16:02 prolink007

So the reason these events aren't working for ion-input is because the blur and focus events do not bubble up from the native input, see: blur & focus.

We are now emitting these events from the ion-input. This should be fixed in the next release (beta.4), thanks!

brandyscarney avatar Mar 16 '16 16:03 brandyscarney

Are you sure this issue is closed ? I have the same bug in 2.1.0.

This line doesn't fire the function: <ion-input type="datetime-local" formControlName="begin" (blur)="updateEndDate($event)"></ion-input>

But this one does: <ion-input type="datetime-local" formControlName="begin" (focusout)="updateEndDate($event)"></ion-input>

Tested on Chrome.

Gp2mv3 avatar Mar 03 '17 17:03 Gp2mv3

@Gp2mv3 I'm not seeing any issues using either type="text" or type="datetime-local". Could you see if changing the type does anything? What element are you clicking on to blur to it?

brandyscarney avatar Mar 03 '17 20:03 brandyscarney

@brandyscarney I'm using ionic-angular 3.5.0, and can confirm that neither (blur) nor (focus) events are fired properly still.

(focusout) does work though, even the docs state clearly that (blur) and (focus) are the appropriate events.

What worked for me: <ion-input type="text" formControlName="answer" (focusout)="onBlur()"></ion-input>

sharonswli avatar Jul 06 '17 20:07 sharonswli

<ion-input [type]=" !showPassword ? 'password' : 'text' "> when I try to change the showPassword by pressing the button <button (tap)="showPassword = !showPassword; $event.preventDefault()"> ion-input loses focus, respectively, the keyboard disappears on the device. Using <ion-input (focusout)="$event.preventDefault()"> does not help. Somebody has speculation why?

Smoke1987 avatar Sep 12 '17 06:09 Smoke1987

This worked for me. <ion-input type="text" (ionBlur)="onBlur()">

biranchi2018 avatar Feb 07 '18 06:02 biranchi2018

How to blur an ion-input programmatically?

Corona17 avatar Mar 07 '18 23:03 Corona17

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 01 '18 07:09 ionitron-bot[bot]