diff --git a/core/src/components/input/input-interface.ts b/core/src/components/input/input-interface.ts index 6b87d102a4..a03fbae922 100644 --- a/core/src/components/input/input-interface.ts +++ b/core/src/components/input/input-interface.ts @@ -1,12 +1,17 @@ +/** + * Values are converted to strings when emitted which is + * why we do not have a `number` type here even though the + * `value` prop accepts a `number` type. + */ export interface InputChangeEventDetail { - value?: string | number | null; + value?: string | null; event?: Event; } // We recognize that InputInput is not an ideal naming pattern for this type. // TODO (FW-2199): Explore renaming this type to something more appropriate. export interface InputInputEventDetail { - value?: string | number | null; + value?: string | null; event?: Event; } diff --git a/core/src/components/input/input.tsx b/core/src/components/input/input.tsx index 4ce1f39156..166f5c2539 100644 --- a/core/src/components/input/input.tsx +++ b/core/src/components/input/input.tsx @@ -424,7 +424,11 @@ export class Input implements ComponentInterface { */ private emitInputChange(event?: Event) { const { value } = this; - this.ionInput.emit({ value, event }); + + // Checks for both null and undefined values + const newValue = value == null ? value : value.toString(); + + this.ionInput.emit({ value: newValue, event }); } private shouldClearOnEdit() {