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:
Amanda Johnston
2022-11-09 13:55:20 -06:00
committed by GitHub
parent d72390132a
commit c45d05476b
7 changed files with 35 additions and 11 deletions

View File

@ -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: