|
5 | 5 | inject, |
6 | 6 | input, |
7 | 7 | output, |
| 8 | + signal, |
8 | 9 | } from '@angular/core'; |
9 | 10 | import { toSignal } from '@angular/core/rxjs-interop'; |
10 | 11 | import { FormControl, ReactiveFormsModule } from '@angular/forms'; |
@@ -109,14 +110,15 @@ import { faro } from '@grafana/faro-web-sdk'; |
109 | 110 | trigger.closePanel(); |
110 | 111 | auto._isOpen = false |
111 | 112 | " |
| 113 | + (input)="keepSearchKeyword.set(searchKeyword.value || '')" |
112 | 114 | [formControl]="searchKeyword" |
113 | 115 | [matAutocomplete]="auto" |
114 | 116 | #trigger="matAutocompleteTrigger" |
115 | 117 | /> |
116 | 118 | <mat-autocomplete |
117 | 119 | #auto="matAutocomplete" |
118 | 120 | panelWidth="auto" |
119 | | - (optionSelected)="optionSelected($event, $any(input).value)" |
| 121 | + (optionSelected)="optionSelected($event)" |
120 | 122 | (opened)="searchPanelOpened()" |
121 | 123 | (closed)="searchPanelClosed()" |
122 | 124 | > |
@@ -150,6 +152,8 @@ export class LayoutToolbarComponent { |
150 | 152 | protected isSmallScreen = this.platformService.isSmallScreen; |
151 | 153 | protected searchKeyword = new FormControl<string>(''); |
152 | 154 |
|
| 155 | + protected keepSearchKeyword = signal(''); |
| 156 | + |
153 | 157 | private suggestList$ = combineLatest([ |
154 | 158 | this.sitePostService.postsMetaWithSlugAndSortDesc$, |
155 | 159 | this.searchKeyword.valueChanges.pipe( |
@@ -185,10 +189,9 @@ export class LayoutToolbarComponent { |
185 | 189 |
|
186 | 190 | protected optionSelected( |
187 | 191 | event: MatAutocompleteSelectedEvent, |
188 | | - keyword: string, |
189 | 192 | ) { |
190 | 193 | faro.api.pushEvent('suggest-item-selected', { |
191 | | - keyword, |
| 194 | + keyword: this.keepSearchKeyword(), |
192 | 195 | link: event.option.value.link, |
193 | 196 | type: event.option.value.type, |
194 | 197 | title: event.option.value.text, |
|
0 commit comments