Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0.0-beta.7] ion-item ionChange event firing for every keypress #15442

Closed
ajmchambers opened this issue Sep 2, 2018 · 3 comments
Closed

[4.0.0-beta.7] ion-item ionChange event firing for every keypress #15442

ajmchambers opened this issue Sep 2, 2018 · 3 comments
Labels

Comments

@ajmchambers
Copy link

Bug Report

Ionic Info
@ionic/core : 4.0.0-beta.7

Describe the Bug
ion-input fires the ionChange event for every keypress, rather than when the input's value has changed and has been committed.

Steps to Reproduce
Add an ionChange event listener to an ion-input element, then type into the input

Related Code
a JSFiddle example with ion-input and regular input for comparison (check console output):

<ion-card>
   <ion-item>
     <ion-label position="stacked">Test Field</ion-label>
     <ion-input></ion-input>
   </ion-item> 
</ion-card>
<input type="text" />
var ionInput = document.querySelector('ion-input');
var input = document.querySelector('input');

ionInput.addEventListener('ionChange', function() {
  console.log('ionChange event fired');
});
input.addEventListener('change', function() {
  console.log('change event fired'); 
});

Expected Behavior
'ionChange' event should behave like a regular input 'change' event where the event is only fired when the value has changed and the field is exited.

@ionitron-bot ionitron-bot bot added the triage label Sep 2, 2018
@manucorporat
Copy link
Contributor

This is by design, ionChange is fired every time the input.value changes, feel free to use the debounce prop, in order to reduce the number of times ionChange is called!

@Matttaylor8910
Copy link

Matttaylor8910 commented Sep 11, 2018

feel free to use the debounce prop

Hello @manucorporat, I agree with @ajmchambers that this is a bug, or at the very least a feature request, I am using (ionChange)="someFunction()" with debounce="500" on an , and the function is still called immediately. Debounce doesn't seem to be implemented for . Could you clarify what you meant?

<ion-input type="text" placeholder="Email Address" [(ngModel)]="service.user.email" (ionChange)="emailChanged()" debounce="500"></ion-input>

Edit: I see you worked on #6936 two years ago, maybe your suggestion to spread the debounce love to other components didn't get finished?

@ionitron-bot
Copy link

ionitron-bot bot commented Oct 11, 2018

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 ionitron-bot bot locked and limited conversation to collaborators Oct 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants