From c7153a5f567cdaab79134e5ca0d1fff32cbea2bb Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 12 Jun 2026 17:22:16 +0300 Subject: [PATCH] fix(iot-hub): preserve typed search text when picking an autocomplete result Drop the (optionSelected) handler and route navigation through the option's (click) instead. Setting [value]="searchText" makes Material write the typed string back through ngModel (a no-op) rather than the MpItemVersionView object, so the input keeps the user's query after the detail dialog closes and searchText.trim() in seeAllResults() stays safe. --- .../home/pages/iot-hub/iot-hub-home.component.html | 3 +-- .../modules/home/pages/iot-hub/iot-hub-home.component.ts | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html index f9f7285c3b..71506d090e 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.html @@ -78,7 +78,6 @@ @if (searchLoading) { @@ -99,7 +98,7 @@ @for (group of searchResultGroups; track group.type) { @for (item of group.items; track item.id) { - + @if (isCompactType(item.type)) {
{{ getCompactIcon(item) }} diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts index c8fff1ea7e..87f8eee0b2 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-home.component.ts @@ -17,7 +17,6 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core'; import { Router } from '@angular/router'; import { MatAutocompleteTrigger } from '@angular/material/autocomplete'; -import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete'; import { BreakpointObserver } from '@angular/cdk/layout'; import { forkJoin, Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators'; @@ -235,13 +234,6 @@ export class TbIotHubHomeComponent implements OnInit, OnDestroy { return typeof value === 'string' ? value : this.searchText || ''; }; - onSearchOptionSelected(event: MatAutocompleteSelectedEvent): void { - const item = event.option.value as MpItemVersionView; - this.searchText = ''; - this.searchAutoTrigger?.closePanel(); - this.openItemDetail(item); - } - clearSearch(): void { this.searchText = ''; this.searchSubject.next('');