feat(input): debounce controls the timing to delay the ionInput event (#25969)

This commit is contained in:
Sean Perkins
2022-09-20 13:10:50 -04:00
committed by GitHub
parent b4e18494b1
commit 35041b2f3c
3 changed files with 8 additions and 6 deletions

View File

@ -63,9 +63,11 @@ This section details the desktop browser, JavaScript framework, and mobile platf
<h4 id="version-7x-input">Input</h4>
`ionChange` is no longer emitted when the `value` of `ion-input` is modified externally. `ionChange` is only emitted from user committed changes, such as typing in the input and the input losing focus or from clicking the clear action within the input.
- `ionChange` is no longer emitted when the `value` of `ion-input` is modified externally. `ionChange` is only emitted from user committed changes, such as typing in the input and the input losing focus or from clicking the clear action within the input.
If your application requires immediate feedback based on the user typing actively in the input, consider migrating your event listeners to using `ionInput` instead.
- If your application requires immediate feedback based on the user typing actively in the input, consider migrating your event listeners to using `ionInput` instead.
- The `debounce` property has been updated to control the timing in milliseconds to delay the event emission of the `ionInput` event after each keystroke. Previously it would delay the event emission of `ionChange`.
<h4 id="version-7x-overlays">Overlays</h4>

View File

@ -1068,7 +1068,7 @@ export namespace Components {
*/
"color"?: Color;
/**
* Set the amount of time, in milliseconds, to wait to trigger the `ionChange` event after each keystroke. This also impacts form bindings such as `ngModel` or `v-model`.
* Set the amount of time, in milliseconds, to wait to trigger the `ionInput` event after each keystroke.
*/
"debounce": number;
/**
@ -4857,7 +4857,7 @@ declare namespace LocalJSX {
*/
"color"?: Color;
/**
* Set the amount of time, in milliseconds, to wait to trigger the `ionChange` event after each keystroke. This also impacts form bindings such as `ngModel` or `v-model`.
* Set the amount of time, in milliseconds, to wait to trigger the `ionInput` event after each keystroke.
*/
"debounce"?: number;
/**

View File

@ -92,13 +92,13 @@ export class Input implements ComponentInterface {
@Prop() clearOnEdit?: boolean;
/**
* Set the amount of time, in milliseconds, to wait to trigger the `ionChange` event after each keystroke. This also impacts form bindings such as `ngModel` or `v-model`.
* Set the amount of time, in milliseconds, to wait to trigger the `ionInput` event after each keystroke.
*/
@Prop() debounce = 0;
@Watch('debounce')
protected debounceChanged() {
this.ionChange = debounceEvent(this.ionChange, this.debounce);
this.ionInput = debounceEvent(this.ionInput, this.debounce);
}
/**