input with action mark for check on reset

This commit is contained in:
Dan Percic 2021-10-14 23:51:02 +03:00
parent c16328aa38
commit f7d8b556d3

View File

@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
@Component({
selector: 'iqser-input-with-action',
@ -16,6 +16,8 @@ export class InputWithActionComponent {
@Output() readonly action = new EventEmitter<string>();
@Output() readonly valueChange = new EventEmitter<string>();
constructor(private readonly _changeDetectorRef: ChangeDetectorRef) {}
get hasContent(): boolean {
return !!this.value?.length;
}
@ -24,13 +26,14 @@ export class InputWithActionComponent {
return this.width === 'full' ? '100%' : `${this.width}px`;
}
get isSearch(): boolean {
return this.action.observers.length === 0;
}
reset(): void {
this.value = '';
this.valueChange.emit(this.value);
}
get isSearch(): boolean {
return this.action.observers.length === 0;
this._changeDetectorRef.markForCheck();
}
executeAction($event: MouseEvent): void {