bug: ionChange event on ion-Range is a customEvent
See original GitHub issueBug Report
Ionic version:
[x] 4.11.10
Current behavior:
By using (ionChange) with exampleFunction($event) the event Param is always a CustomEvent and not an event with information about the ion-range.
Expected behavior:
In older versions of Ionic there has been infos about the range (like isFocus, value, etc.)
Steps to reproduce:
- create ionic starter project
- in template put
<ion-range></ion-range>
in ion-content section and add(ionChange)=changeFunction($event)
.<ion-range (ionChange)="changeFunction($event)"></ion-range>
- in .ts file add the changeFunction($event) to the class
- start ionic serve
- check browser console for Custom event
Related code: Template:
<ion-range (ionChange)="changeFunction($event)"></ion-range>
ts-File:
changeFunction(event){
console.log(event);
}
Other information:
Ionic info:
Ionic:
Ionic CLI : 6.0.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 4.11.10
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.4.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0, browser 5.0.4, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 26 other plugins)
Utility:
cordova-res : 0.9.0
native-run : 0.3.0
System:
ios-deploy : 1.9.2
ios-sim : 8.0.2
NodeJS : v12.14.1 (/usr/local/bin/node)
npm : 6.13.6
OS : macOS Mojave
Xcode : Xcode 11.3.1 Build version 11C504
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
bug: ionChange event on ion-Range is a customEvent #20355
By using (ionChange) with exampleFunction($event) the event Param is always a CustomEvent and not an event with information about the ion-range.
Read more >Ionic ion-range events all Custom-Events? - Ionic Forum
No matter which event I use. I always get back a “CustomEvent”. Template: <ion-range (ionChange)="change($event)"></ion-range>. and ts-file:
Read more >Error in onChange of an ion-range in ionic 3 - Stack Overflow
I could not find the solution for this way of using the range. But I was able to achieve the goal by changing...
Read more >Custom event types in Ionic | Damir's Corner
In Ionic 6, component events have well-documented, strongly typed arguments. This should allow them to be used in such event handlers:
Read more >Ionic Forum - Latest posts - RSSing.com
No matter which event I use. I always get back a “CustomEvent”. Template: <ion-range (ionChange)="change($event)"></ion-range>. and ts-file: change(value) {
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@NikolaPeevski thanks for the info. Not sure with the progress-bar because I want to let the user click on the progress-bar to forward and backward the media. But anyway. For me this issue is resolved because I missunderstood those events ionFocus and ionBlur.
I thought they both should deliver the value, but if it was always planned that they don’t it is fine.
Thanks for the support and the quick answers.
@NeckbreakerPascal Thinks of ionFocus and ionBlur as two focus related events. ionFocus will fire when the element is focused and ionBlur will fire after the focus of an element is removed. If you take the example of ion-range when you try to toggle the range (ie. click and drag) ionFocus will fire, when you let go and stop dragging the knob ionBlur will fire. Both events have a slight (I think 2 seconds) debounce timer so if you were to toggle the knob and then immediately toggle it again you’ll still get only one ionFocus and ionBlur trigger. You can checkout https://ionicframework.com/docs/api/progress-bar it might fit your case better. And lastly they don’t send the value. The ionChange emits the value every time there is a change in the range component, one tip to reduce the event spam is to pipe-debounce it and return the ionChange result similarly to how ionFocus/Blur are implemented.
@brandyscarney is this issue resolved and closable ?