From ffc81b74de70dcc989331545f8352c16cc07f20a Mon Sep 17 00:00:00 2001 From: Adithya Sreyaj Date: Tue, 15 Feb 2022 14:02:32 +0530 Subject: [PATCH] fix(input): reset on input component not working fix --- projects/components/src/input/input.component.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/projects/components/src/input/input.component.ts b/projects/components/src/input/input.component.ts index 9e4426110..41849d17f 100644 --- a/projects/components/src/input/input.component.ts +++ b/projects/components/src/input/input.component.ts @@ -1,4 +1,12 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + EventEmitter, + Input, + OnChanges, + Output +} from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { NumberCoercer, TypedSimpleChanges } from '@hypertrace/common'; import { InputAppearance } from './input-appearance'; @@ -54,6 +62,8 @@ export class InputComponent implements ControlValueAc public placeholderValue: string = ''; + public constructor(private readonly cdr: ChangeDetectorRef) {} + public ngOnChanges(changes: TypedSimpleChanges): void { if (changes.placeholder) { this.placeholderValue = this.placeholder ?? ''; @@ -77,6 +87,7 @@ export class InputComponent implements ControlValueAc public writeValue(value?: string): void { const coercedValue = this.coerceValueIfNeeded(value); this.value = coercedValue; + this.cdr.markForCheck(); } public registerOnChange(onChange: (value: T | undefined) => void): void {