diff --git a/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.html b/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.html index 37a2e9c369b..e0bf9d9703b 100644 --- a/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.html +++ b/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.html @@ -20,7 +20,7 @@ [ixTest]="controlDirective.name" [class.has-value]="selectedOption?.label || textContent" (input)="onChanged(ixInput.value)" - (blur)="onTouch()" + (blur)="inputBlurred()" /> @if (loading) { diff --git a/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.ts b/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.ts index b38f51ac701..ae7a4ae2dc5 100644 --- a/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.ts +++ b/src/app/modules/forms/ix-forms/components/ix-combobox/ix-combobox.component.ts @@ -74,10 +74,6 @@ export class IxComboboxComponent implements ControlValueAccessor, OnInit { if (this.value && this.options?.length) { this.selectedOption = { ...(this.options.find((option: Option) => option.value === this.value)) }; } - if (this.selectedOption) { - this.filterChanged$.next(''); - } - this.cdr.markForCheck(); } @@ -101,6 +97,14 @@ export class IxComboboxComponent implements ControlValueAccessor, OnInit { this.filterChanged$.next(''); } + inputBlurred(): void { + this.onTouch(); + + if (!this.allowCustomValue && !this.selectedOption) { + this.resetInput(); + } + } + filterOptions(filterValue: string): void { this.loading = true; this.cdr.markForCheck(); @@ -124,10 +128,6 @@ export class IxComboboxComponent implements ControlValueAccessor, OnInit { this.selectedOption = selectedOptionFromValue ? { ...selectedOptionFromValue } : { label: this.value as string, value: this.value }; - - if (this.selectedOption.value) { - this.filterChanged$.next(''); - } } this.loading = false; @@ -193,7 +193,7 @@ export class IxComboboxComponent implements ControlValueAccessor, OnInit { } onChanged(changedValue: string): void { - if (this.selectedOption || this.value) { + if (this.selectedOption?.value || this.value) { this.resetInput(); } this.textContent = changedValue;