diff --git a/web/src/user/LibraryPage/ApplicationSearch.ts b/web/src/user/LibraryPage/ApplicationSearch.ts index a37975f67..c6c104223 100644 --- a/web/src/user/LibraryPage/ApplicationSearch.ts +++ b/web/src/user/LibraryPage/ApplicationSearch.ts @@ -16,10 +16,6 @@ import type { Application } from "@goauthentik/api"; import { SEARCH_ITEM_SELECTED, SEARCH_UPDATED } from "./constants"; import { customEvent } from "./helpers"; -function fuseToApps(apps: Fuse.FuseResult[]): Application[] { - return apps.map((item) => item.item); -} - @customElement("ak-library-list-search") export class LibraryPageApplicationList extends AKElement { static styles = [PFBase, PFDisplay]; @@ -55,16 +51,15 @@ export class LibraryPageApplicationList extends AKElement { } onSelected(apps: Fuse.FuseResult[]) { - const items = fuseToApps(apps); this.dispatchEvent( customEvent(SEARCH_UPDATED, { - selectedApp: items[0], - filteredApps: items, + apps: apps.map((app) => app.item), }), ); } connectedCallback() { + super.connectedCallback(); this.fuse.setCollection(this.apps); if (!this.query) { return; diff --git a/web/src/user/LibraryPage/LibraryPageImpl.ts b/web/src/user/LibraryPage/LibraryPageImpl.ts index ce75cc9f3..9f8d50e26 100644 --- a/web/src/user/LibraryPage/LibraryPageImpl.ts +++ b/web/src/user/LibraryPage/LibraryPageImpl.ts @@ -85,8 +85,13 @@ export class LibraryPage extends AKElement { throw new Error("ak-library-search-updated must send a custom event."); } event.stopPropagation(); - this.selectedApp = event.detail.apps[0]; - this.filteredApps = event.detail.apps; + const apps = event.detail.apps; + this.selectedApp = undefined; + this.filteredApps = this.apps.results; + if (apps.length > 0) { + this.selectedApp = apps[0]; + this.filteredApps = event.detail.apps; + } } launchRequest(event: Event) { @@ -125,7 +130,7 @@ export class LibraryPage extends AKElement { } renderSearch() { - return html``; + return html``; } render() {