mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
feat(input, textarea): change default debounce to undefined (#26073)
Co-authored-by: Sean Perkins <sean@ionic.io> Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
This commit is contained in:
@ -30,6 +30,8 @@ export class Input implements ComponentInterface {
|
||||
private inputId = `ion-input-${inputIds++}`;
|
||||
private inheritedAttributes: Attributes = {};
|
||||
private isComposing = false;
|
||||
private originalIonInput?: EventEmitter<InputInputEventDetail>;
|
||||
|
||||
/**
|
||||
* `true` if the input was cleared as a result of the user typing
|
||||
* with `clearOnEdit` enabled.
|
||||
@ -93,11 +95,17 @@ export class Input implements ComponentInterface {
|
||||
/**
|
||||
* Set the amount of time, in milliseconds, to wait to trigger the `ionInput` event after each keystroke.
|
||||
*/
|
||||
@Prop() debounce = 0;
|
||||
@Prop() debounce?: number;
|
||||
|
||||
@Watch('debounce')
|
||||
protected debounceChanged() {
|
||||
this.ionInput = debounceEvent(this.ionInput, this.debounce);
|
||||
const { ionInput, debounce, originalIonInput } = this;
|
||||
|
||||
/**
|
||||
* If debounce is undefined, we have to manually revert the ionInput emitter in case
|
||||
* debounce used to be set to a number. Otherwise, the event would stay debounced.
|
||||
*/
|
||||
this.ionInput = debounce === undefined ? originalIonInput ?? ionInput : debounceEvent(ionInput, debounce);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,6 +301,7 @@ export class Input implements ComponentInterface {
|
||||
}
|
||||
|
||||
componentDidLoad() {
|
||||
this.originalIonInput = this.ionInput;
|
||||
const nativeInput = this.nativeInput;
|
||||
if (nativeInput) {
|
||||
// TODO: FW-729 Update to JSX bindings when Stencil resolves bug with:
|
||||
|
||||
Reference in New Issue
Block a user