@@ -180,37 +209,36 @@ export class LibraryPage extends AKElement { ? html` { this.query = (ev.target as HTMLInputElement).value; + if (this.query === "") { + return this.resetSearch(); + } updateURLParams({ search: this.query, }); - if (!this.fuse) return; const apps = this.fuse.search(this.query); if (apps.length < 1) return; this.selectedApp = apps[0].item; + this.filteredApps = apps.map((a) => a.item); }} @keydown=${(ev: KeyboardEvent) => { if (ev.key === "Enter" && this.selectedApp?.launchUrl) { window.location.assign(this.selectedApp.launchUrl); } else if (ev.key === "Escape") { - (ev.target as HTMLInputElement).value = ""; - this.query = ""; - updateURLParams({ - search: this.query, - }); - this.selectedApp = undefined; + this.resetSearch(); } }} type="text" class="pf-u-display-none pf-u-display-block-on-md" autofocus placeholder=${t`Search...`} + value=${ifDefined(this.query)} />` : html``}
${loading( this.apps, - html`${this.filterApps().length > 0 + html`${this.filteredApps.length > 0 ? this.renderApps() : this.renderEmptyState()}`, )}