Add slClear event to input

pull/186/head
Cory LaViska 2020-08-25 16:24:33 -04:00
rodzic de1daad04e
commit e169c937df
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -118,6 +118,9 @@ export class Input {
/** Emitted when the control's value changes. */
@Event() slChange: EventEmitter;
/** Emitted when the clear button is activated. */
@Event() slClear: EventEmitter;
/** Emitted when the control receives input. */
@Event() slInput: EventEmitter;
@ -196,13 +199,15 @@ export class Input {
this.slFocus.emit();
}
handleClearClick() {
handleClearClick(event: MouseEvent) {
if (this.input.value !== '') {
this.input.value = '';
this.input.dispatchEvent(new window.Event('input', { bubbles: true }));
this.input.dispatchEvent(new window.Event('change', { bubbles: true }));
}
event.stopPropagation();
this.slClear.emit();
this.input.focus();
}