Skip to content

Commit

Permalink
Merge pull request #192 from zugdev/fix/modal-search-clear
Browse files Browse the repository at this point in the history
fix/modal search clear
  • Loading branch information
zugdev authored Jan 5, 2025
2 parents a721d41 + e4e9cba commit 635845a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/home/fetch-github/fetch-and-display-previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
17 changes: 11 additions & 6 deletions src/home/sorting/sorting-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand All @@ -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);
}
Expand Down

0 comments on commit 635845a

Please sign in to comment.