From d02f41e2bdaa9b04b8d060ebc4d537f9e94ac28e Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 3 May 2025 23:09:21 +0200 Subject: [PATCH] fix(quote search): uncaught errors when closing modal right after search input !nuf --- frontend/src/ts/modals/quote-search.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/ts/modals/quote-search.ts b/frontend/src/ts/modals/quote-search.ts index eed7bb36c..c3db661e0 100644 --- a/frontend/src/ts/modals/quote-search.ts +++ b/frontend/src/ts/modals/quote-search.ts @@ -62,6 +62,7 @@ function highlightMatches(text: string, matchedText: string[]): string { } function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { + if (!modal.isOpen()) return []; const quoteLengthFilterValue = $( "#quoteSearchModal .quoteLengthFilter" ).val() as string[]; @@ -80,6 +81,7 @@ function applyQuoteLengthFilter(quotes: Quote[]): Quote[] { } function applyQuoteFavFilter(quotes: Quote[]): Quote[] { + if (!modal.isOpen()) return []; const showFavOnly = ( document.querySelector(".toggleFavorites") as HTMLDivElement ).classList.contains("active"); @@ -154,6 +156,8 @@ function buildQuoteSearchResult( } async function updateResults(searchText: string): Promise { + if (!modal.isOpen()) return; + const { quotes } = await QuotesController.getQuotes(Config.language); const quoteSearchService = getSearchService( @@ -334,6 +338,7 @@ function apply(val: number): void { } const searchForQuotes = debounce(250, (): void => { + if (!modal.isOpen()) return; const searchText = (document.getElementById("searchBox") as HTMLInputElement) .value; currentPageNumber = 1;