mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
feat(searchbar): ionChange will only emit from user committed changes (#26026)
This commit is contained in:
@ -4,8 +4,7 @@ import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { ValueAccessor } from './value-accessor';
|
||||
|
||||
@Directive({
|
||||
/* tslint:disable-next-line:directive-selector */
|
||||
selector: 'ion-searchbar',
|
||||
selector: 'ion-input:not([type=number]),ion-textarea,ion-searchbar',
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
@ -19,28 +18,6 @@ export class TextValueAccessorDirective extends ValueAccessor {
|
||||
super(injector, el);
|
||||
}
|
||||
|
||||
@HostListener('ionChange', ['$event.target'])
|
||||
_handleInputEvent(el: any): void {
|
||||
this.handleValueChange(el, el.value);
|
||||
}
|
||||
}
|
||||
|
||||
@Directive({
|
||||
selector: 'ion-input:not([type=number]),ion-textarea',
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: InputValueAccessorDirective,
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
// 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);
|
||||
}
|
||||
|
||||
@HostListener('ionInput', ['$event.target'])
|
||||
_handleInputEvent(el: any): void {
|
||||
this.handleValueChange(el, el.value);
|
||||
|
||||
@ -1518,11 +1518,17 @@ export class IonRow {
|
||||
import type { SearchbarChangeEventDetail as ISearchbarSearchbarChangeEventDetail } from '@ionic/core';
|
||||
export declare interface IonSearchbar extends Components.IonSearchbar {
|
||||
/**
|
||||
* Emitted when a keyboard input occurred.
|
||||
* Emitted when the `value` of the `ion-searchbar` element has changed.
|
||||
*/
|
||||
ionInput: EventEmitter<CustomEvent<KeyboardEvent>>;
|
||||
ionInput: EventEmitter<CustomEvent<KeyboardEvent | null>>;
|
||||
/**
|
||||
* Emitted when the value has changed.
|
||||
* The `ionChange` event is fired for `<ion-searchbar>` 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. This includes modifications made when clicking the clear
|
||||
or cancel buttons.
|
||||
*/
|
||||
ionChange: EventEmitter<CustomEvent<ISearchbarSearchbarChangeEventDetail>>;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user