Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/modal search clear #192

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading