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

[Issue #1491]: Setup states to hide clear all and select all in filter accordion #1495

Merged
merged 8 commits into from
Mar 19, 2024

Conversation

rylew1
Copy link
Contributor

@rylew1 rylew1 commented Mar 18, 2024

Summary

Fixes #1491

Time to review: 10 min

Changes proposed

  • add states for tracking clear all / select all
    • states are passed down through accordion filter
  • move searchfetcher classes to /services/search/searchfetcher folder

Context for reviewers

Demo

Screen.Recording.2024-03-18.at.2.11.50.PM.mov

@@ -10,7 +10,7 @@ import SearchCallToAction from "../../components/search/SearchCallToAction";
import { SearchForm } from "./SearchForm";
import { convertSearchParamsToProperTypes } from "../../utils/convertSearchParamsToStrings";
import { cookies } from "next/headers";
import { getSearchFetcher } from "../../services/searchfetcher/SearchFetcherUtil";
import { getSearchFetcher } from "../../services/search/searchfetcher/SearchFetcherUtil";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also moved the SearchFetcher classes from /services/searchfetcher to services/search/searchfetcher/ so there's a bunch of updates in this PR for that

@rylew1 rylew1 requested review from andycochran, acouch, coilysiren and chouinar and removed request for andycochran, acouch and SammySteiner March 18, 2024 21:18
: undefined,
}));
};
}
Copy link
Contributor Author

@rylew1 rylew1 Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start the creation of a SearchFilterManager class (currently not used). I think we should start to move some of the management of checked options here (how many total checked, how many in a section are checked, if all in a section are checked are not) - to make it easy to just grab these values instead of looping through all the options everytime. We still want useSearchFilter I think for react things like mounted, possibly calling the setter functions of useStates'

It probably won't lead to a ton of performance improvement though - just more for our own sanity :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might try this in a part 2 PR on this #1491 ticket

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Should we put a TODO in this file noting as much (that it's not being used yet and a link to a ticket to implement/explore)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea good catch - will add that!

const [isSectionNoneSelected, setIsSectionNoneSelected] = useState<{
[key: string]: boolean;
}>(initialSelectionStates.isSectionNoneSelected);

Copy link
Contributor Author

@rylew1 rylew1 Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loads of logic to manage the {select,clear} all disabled state for both sections and non-sections

@@ -84,6 +90,8 @@ export function SearchFilterAccordion({
mounted={mounted}
updateCheckedOption={toggleOptionChecked}
toggleSelectAll={toggleSelectAll}
isSectionAllSelected={isSectionAllSelected[option.id]}
isSectionNoneSelected={isSectionNoneSelected[option.id]}
/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the logic to setup those values is kind of a lot but once you have it it's very easy to use in the components

: undefined,
}));
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Should we put a TODO in this file noting as much (that it's not being used yet and a link to a ticket to implement/explore)?

@rylew1 rylew1 merged commit 805583a into main Mar 19, 2024
9 checks passed
@rylew1 rylew1 deleted the rylew/1491-selectAll-clearAll-disabled branch March 19, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[Task]: Disable select all when all selected. Disable clear all when none selected.
2 participants