diff --git a/src/home/fetch-github/fetch-and-display-previews.ts b/src/home/fetch-github/fetch-and-display-previews.ts index 442393b..fb4603a 100644 --- a/src/home/fetch-github/fetch-and-display-previews.ts +++ b/src/home/fetch-github/fetch-and-display-previews.ts @@ -14,17 +14,17 @@ export type Options = { }; // decide initial value based on URL -export let isFilteringAvailableIssues = (new URLSearchParams(window.location.search).get("allIssues") === "true") ? false : true; +export let isFilteringAvailableIssues = new URLSearchParams(window.location.search).get("allIssues") === "true" ? false : true; export function swapAvailabilityFilter() { isFilteringAvailableIssues = !isFilteringAvailableIssues; //url part const newURL = new URL(window.location.href); - if(isFilteringAvailableIssues){ - newURL.searchParams.delete("allIssues") - } else { - newURL.searchParams.set("allIssues","true"); + if (isFilteringAvailableIssues) { + newURL.searchParams.delete("allIssues"); + } else { + newURL.searchParams.set("allIssues", "true"); } console.log(newURL.toString()); window.history.replaceState({}, "", newURL.toString()); diff --git a/src/home/sorting/sorting-manager.ts b/src/home/sorting/sorting-manager.ts index 58437cf..3d6ff2b 100644 --- a/src/home/sorting/sorting-manager.ts +++ b/src/home/sorting/sorting-manager.ts @@ -174,7 +174,7 @@ export class SortingManager { input.value = "Unassigned"; input.id = `filter-availability-${this._instanceId}`; // decide initial value based on URL - if(new URLSearchParams(window.location.search).get("allIssues") === "true"){ + if (new URLSearchParams(window.location.search).get("allIssues") === "true") { input.value = "All Issues"; } @@ -183,11 +183,16 @@ export class SortingManager { input.value = isFilteringAvailableIssues ? "Unassigned" : "All Issues"; try { - const { sortingOption, sortingOrder } = this._detectSortingState(); - void displayGitHubIssues({ - sorting: sortingOption as Sorting, - options: { ordering: sortingOrder }, - }); + const filterTextBox = this._filtersDiv.querySelector('input[type="text"]') as HTMLInputElement; + if (filterTextBox.value) { + void searchDisplayGitHubIssues({ searchText: filterTextBox.value }); + } else { + const { sortingOption, sortingOrder } = this._detectSortingState(); + void displayGitHubIssues({ + sorting: sortingOption as Sorting, + options: { ordering: sortingOrder }, + }); + } } catch (error) { renderErrorInModal(error as Error); }