diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.html
index 369d6fa180..c78f30f1ed 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.html
@@ -40,7 +40,7 @@
class="tb-autocomplete"
[displayWith]="displayObjectLwm2mFn">
-
+
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts
index c3a0e1e4b3..642ca905ae 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts
@@ -112,15 +112,15 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
ngOnInit() {
this.filteredObjectsList = this.lwm2mListFormGroup.get('objectLwm2m').valueChanges
.pipe(
- distinctUntilChanged(),
tap((value) => {
- if (value && typeof value !== 'string') {
+ if (value && !isString(value)) {
this.add(value);
} else if (value === null) {
- this.clear();
+ this.clear(this.objectInput.nativeElement.value);
}
}),
filter(searchText => isString(searchText)),
+ distinctUntilChanged(),
mergeMap(searchText => this.fetchListObjects(searchText)),
share()
);
@@ -176,8 +176,8 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
}
}
- displayObjectLwm2mFn = (object?: ObjectLwM2M): string | undefined => {
- return object ? object.name : undefined;
+ displayObjectLwm2mFn = (object?: ObjectLwM2M): string => {
+ return object ? object.name : '';
}
private fetchListObjects = (searchText: string): Observable> => {
@@ -196,9 +196,9 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
}
}
- private clear() {
- this.searchText = '';
- this.lwm2mListFormGroup.get('objectLwm2m').patchValue(null, {emitEvent: false});
+ private clear(value: string = '') {
+ this.objectInput.nativeElement.value = value;
+ this.lwm2mListFormGroup.get('objectLwm2m').patchValue(value);
setTimeout(() => {
this.objectInput.nativeElement.blur();
this.objectInput.nativeElement.focus();