diff --git a/booklore-ui/src/app/book/components/book-browser/filters/HeaderFilter.ts b/booklore-ui/src/app/book/components/book-browser/filters/HeaderFilter.ts index 6fef337ab..5b978c4c5 100644 --- a/booklore-ui/src/app/book/components/book-browser/filters/HeaderFilter.ts +++ b/booklore-ui/src/app/book/components/book-browser/filters/HeaderFilter.ts @@ -16,7 +16,7 @@ export class HeaderFilter implements BookFilter { distinctUntilChanged(), switchMap(term => { const normalizedTerm = normalize(term || '').trim(); - if (!normalizedTerm) { + if (normalizedTerm.length < 2) { return of(bookState); } return of(normalizedTerm).pipe( diff --git a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts index 3052a3371..8d8a6f28e 100644 --- a/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts +++ b/booklore-ui/src/app/book/components/book-searcher/book-searcher.component.ts @@ -53,7 +53,10 @@ export class BookSearcherComponent implements OnInit, OnDestroy { }) ).subscribe({ next: (filteredState) => { - this.books = this.searchQuery.trim() ? (filteredState.books || []) : []; + const term = this.searchQuery.trim(); + this.books = term.length >= 2 + ? (filteredState.books || []).slice(0, 50) + : []; }, error: (error) => console.error('Subscription error:', error) });