feat(textarea): ionChange will only emit from user committed changes (#25953)

This commit is contained in:
Sean Perkins
2022-09-23 13:26:21 -04:00
committed by GitHub
parent a03c8afb3d
commit 68bae80a51
15 changed files with 280 additions and 33 deletions

View File

@ -5,7 +5,7 @@ import { ValueAccessor } from './value-accessor';
@Directive({
/* tslint:disable-next-line:directive-selector */
selector: 'ion-textarea,ion-searchbar',
selector: 'ion-searchbar',
providers: [
{
provide: NG_VALUE_ACCESSOR,
@ -26,7 +26,7 @@ export class TextValueAccessorDirective extends ValueAccessor {
}
@Directive({
selector: 'ion-input:not([type=number])',
selector: 'ion-input:not([type=number]),ion-textarea',
providers: [
{
provide: NG_VALUE_ACCESSOR,
@ -35,6 +35,7 @@ export class TextValueAccessorDirective extends ValueAccessor {
},
],
})
// TODO rename this value accessor to `TextValueAccessorDirective` when search-bar is updated
export class InputValueAccessorDirective extends ValueAccessor {
constructor(injector: Injector, el: ElementRef) {
super(injector, el);

View File

@ -1816,13 +1816,19 @@ export class IonText {
import type { TextareaChangeEventDetail as ITextareaTextareaChangeEventDetail } from '@ionic/core';
export declare interface IonTextarea extends Components.IonTextarea {
/**
* Emitted when the input value has changed.
* The `ionChange` event is fired for `<ion-textarea>` elements when the user
modifies the element's value. Unlike the `ionInput` event, the `ionChange`
event is not necessarily fired for each alteration to an element's value.
The `ionChange` event is fired when the element loses focus after its value
has been modified.
*/
ionChange: EventEmitter<CustomEvent<ITextareaTextareaChangeEventDetail>>;
/**
* Emitted when a keyboard input occurred.
* Ths `ionInput` event fires when the `value` of an `<ion-textarea>` element
has been changed.
*/
ionInput: EventEmitter<CustomEvent<InputEvent>>;
ionInput: EventEmitter<CustomEvent<InputEvent | null>>;
/**
* Emitted when the input loses focus.
*/