ionic-framework
ionic-framework copied to clipboard
bug: range ionInput event behavior inconsistent with documentation
Prerequisites
- [X] I have read the Contributing Guidelines.
- [X] I agree to follow the Code of Conduct.
- [X] I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x, v8.x
Current Behavior
The onIonInput event behavior isn't consistent with the documentation for the event. This is the current description:
The
ionInputevent is fired for<ion-range>elements when the value is modified. UnlikeionChange,ionInputis fired continuously while the user is dragging the knob.
The actual behavior is that the event is triggered whenever the knob is moved a single pixel (after an initial "sticky" behavior) instead of it triggering whenever the actual value is modified, causing a lot of events being triggered for absolutely no reason. The second part "is fired continously" is ambivalent and could match either expectation.
Expected Behavior
I would expect the event to trigger only when the value is modified rather than when the knob is moved.
Steps to Reproduce
- Open the reproduction Stackblitz link.
- Open the browsers developer console.
- Drag the slider a short distance until the first
ionInputevent is triggered, then keep moving the knob a short distance and see how the event continues to be logged even without the value changing.
Code Reproduction URL
https://stackblitz.com/edit/umlmf6?file=src%2Fmain.tsx
Ionic Info
Ionic:
Ionic CLI : 7.2.0.
Utility:
cordova-res : not installed globally native-run : not installed globally
System:
NodeJS : v20.9.0 npm : 10.1.0 OS : Windows 10 (actual version 11)
Additional Information
As I see it there's 3 possible solutions:
- Only trigger the event when the value has changed from it's previous value as the documentation says.
- Same as 1 but only when
snaps: true. - Update the documentation to not specify
when the value is modifiedbut rather something likewhen the knob is moved.
I believe 1 is the preferable solution, but it might be considered a breaking change and so 2 is a reasonable compromise as there's no practical nor visual updates between value-changes when snaps: true making it a non-breaking change.
3 is by far the least preferable solution in my opinion as this issue is not only a documentation error but the current implementation also carries an unnecessary performance impact (again, at least when snaps: true).
Thank you for the issue! I agree that the best solution would be to match the behavior of native input ranges and only emit the event when the value changes from the previous one. I’ve marked this as a bug, which adds it to our internal issue tracker for further work.
Thank for submitting the issue! This has been resolved via PR https://github.com/ionic-team/ionic-framework/pull/30293 and will be available in an upcoming release of Ionic.
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.