question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$event.target is unavailable from the (ionBlur) event

See original GitHub issue

Ionic version: (check one with “x”) [ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1) [ ] 2.x [X] 3.x

I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior: $event.target is undefined since i have changed the (blur) deprecated event by (ionBlur) event in my template Expected behavior: $event.target property should be available

Steps to reproduce:

Related code:

<ion-input (blur)="onBlur($event)"></ion-input>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
KevinKelchencommented, Nov 24, 2017

The event type change from blur to ionBlur for ion-input seems to have resulted in the $event value passed from the template changing from the native event object to an Ionic TextInput.

I still found a way to access the blur event target but it’s probably not the wisest approach.

Old way with blur:

<ion-input (blur)="onChange($event)">
onChange(event: FocusEvent) {
  const eventTarget = event.target;
}

New way with ionBlur:

<ion-input (ionBlur)="onChange($event)">
onChange(textInput: TextInput) {
  const eventTarget = textInput._native.nativeElement;
}

In the ionBlur scenario, the _native property is labeled with a @hidden comment and it’s excluded from the docs, so it’s probably not considered part of the public API contract.

Would appreciate guidance on a recommended way to access the blur event target! 😃

Thank you!

3reactions
jgw96commented, Jul 5, 2017

Thanks for using Ionic, we will look into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

$event.target is unavailable from the (ionBlur) event #12264
The event type change from blur to ionBlur for ion-input seems to have resulted in the $event value passed from the template changing...
Read more >
ionBlur Event: Detect the element that is receiving the focus
When testing, the event parameter of the onBlur method contains the attributes target and currentTarget which both are the element that is ...
Read more >
ionFocus or ionBlur not working in ios but working in browser
I m using ionic angular, I have added HostListener('ionFocus'), and it is working in the browser without any issue. But when I build...
Read more >
Element: blur event - Web APIs | MDN
The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does...
Read more >
target Event Property - W3Schools
The target property gets the element on which the event originally occurred, opposed to the currentTarget property, which always refers to the element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found