Browse Source

Fixed the Go to search showing the previous user's menu items after Login as or menu changes (#16840)

* Fixed Go to menu search crashing after selecting a link

* PR comments fixes
pull/16142/merge
Maksym Tsymbarov 1 week ago
committed by GitHub
parent
commit
5340d727f8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      ui-ngx/src/app/modules/home/menu/goto-menu.component.html
  2. 9
      ui-ngx/src/app/modules/home/menu/goto-menu.component.ts

4
ui-ngx/src/app/modules/home/menu/goto-menu.component.html

@ -45,7 +45,7 @@
@if (gotoMenuResult.hasMatches) {
@if (gotoMenuResult.nameMatches.length) {
@for (link of gotoMenuResult.nameMatches; track link) {
<mat-option class="tb-goto-menu-link" [value]="null" (onSelectionChange)="gotoLink(link)">
<mat-option class="tb-goto-menu-link" [value]="''" (onSelectionChange)="$event.isUserInput && gotoLink(link)">
<ng-container *ngTemplateOutlet="linkOption; context:{link: link}"></ng-container>
</mat-option>
}
@ -55,7 +55,7 @@
}
@if (gotoMenuResult.crumbMatches.length) {
@for (link of gotoMenuResult.crumbMatches; track link) {
<mat-option class="tb-goto-menu-link" [value]="null" (onSelectionChange)="gotoLink(link)">
<mat-option class="tb-goto-menu-link" [value]="''" (onSelectionChange)="$event.isUserInput && gotoLink(link)">
<ng-container *ngTemplateOutlet="linkOption; context:{link: link}"></ng-container>
</mat-option>
}

9
ui-ngx/src/app/modules/home/menu/goto-menu.component.ts

@ -116,10 +116,10 @@ export class GotoMenuComponent implements OnInit, OnDestroy {
this.router.navigate([link.path], { queryParams: link.queryParams }).then();
}
private fetchLinks(searchText?: string): Observable<GotoMenuResult> {
this.searchText = searchText;
private fetchLinks(searchText: string): Observable<GotoMenuResult> {
const query = (searchText ?? '').trim().toLowerCase();
return this.allLinks().pipe(
map((links) => this.filterLinks(links))
map((links) => this.filterLinks(links, query))
);
}
@ -140,8 +140,7 @@ export class GotoMenuComponent implements OnInit, OnDestroy {
return this.allLinksObservable$;
}
private filterLinks(links: GotoMenuLink[]): GotoMenuResult {
const query = this.searchText.trim().toLowerCase();
private filterLinks(links: GotoMenuLink[], query: string): GotoMenuResult {
const nameMatches: GotoMenuLink[] = [];
let crumbMatches: GotoMenuLink[] = [];
for (const link of links) {

Loading…
Cancel
Save