From f7d8b556d3eb926f8f5fbdfd6663518afc298c9e Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Thu, 14 Oct 2021 23:51:02 +0300 Subject: [PATCH] input with action mark for check on reset --- .../input-with-action.component.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/inputs/input-with-action/input-with-action.component.ts b/src/lib/inputs/input-with-action/input-with-action.component.ts index d0230a4..7bd26f3 100644 --- a/src/lib/inputs/input-with-action/input-with-action.component.ts +++ b/src/lib/inputs/input-with-action/input-with-action.component.ts @@ -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(); @Output() readonly valueChange = new EventEmitter(); + 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 {