diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts index 97f22c5de7..9fc5109450 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts @@ -228,18 +228,32 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit if (value != null) { if (typeof value === 'string') { const targetEntityType = this.checkEntityType(this.entityTypeValue); - this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true}).subscribe( + this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true, ignoreErrors: true}).subscribe( (entity) => { this.modelValue = entity.id.id; this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false}); + }, + () => { + this.modelValue = null; + this.selectEntityFormGroup.get('entity').patchValue(null, {emitEvent: false}); + if (value !== null) { + this.propagateChange(this.modelValue); + } } ); } else { const targetEntityType = this.checkEntityType(value.entityType); - this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true}).subscribe( + this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe( (entity) => { this.modelValue = entity.id.id; this.selectEntityFormGroup.get('entity').patchValue(entity, {emitEvent: false}); + }, + () => { + this.modelValue = null; + this.selectEntityFormGroup.get('entity').patchValue(null, {emitEvent: false}); + if (value !== null) { + this.propagateChange(this.modelValue); + } } ); }