From a15268c1fa01cde3d3a53dba3b2b116c38f27d22 Mon Sep 17 00:00:00 2001 From: Oleksandra Kalinina <946369+korel-san@users.noreply.github.com> Date: Thu, 17 Oct 2024 06:54:20 +0200 Subject: [PATCH] fix update cps-autocomplete component value --- .../cps-autocomplete/cps-autocomplete.component.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.ts b/projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.ts index bfedfcff..6e8d75da 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.ts @@ -651,9 +651,8 @@ export class CpsAutocompleteComponent onBlur() { if (!this.isOpened) { - this._closeAndClear(); + this._confirmInput(this.inputText || '', false); } - this._checkErrors(); this.blurred.emit(); } @@ -971,7 +970,10 @@ export class CpsAutocompleteComponent searchVal = searchVal.toLowerCase(); if (!searchVal) { if (this.multiple) return; - this.updateValue(this._getEmptyValue()); + // Only reset the value if the inputText was changed by the user + if (this.inputText !== this._getValueLabel()) { + this.updateValue(this._getEmptyValue()); + } this.cdRef.detectChanges(); this._closeAndClear(); return;