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 #1489] Complete search filter accordion logic #1490

Merged

Conversation

rylew1
Copy link
Contributor

@rylew1 rylew1 commented Mar 18, 2024

Summary

Fixes #1489

Time to review: 10-15 minutes

Changes proposed

  • Finish debounced update for accordion filter (agency and funding instrument)
    • Accordion filter loads initial state
  • Add custom hook useSearchFormState that wraps the new React useFormState
  • Add tests for custom hooks
  • Explicitly mark client components with use client

Demo

Screen.Recording.2024-03-18.at.7.28.22.AM.mov

@@ -25,6 +29,7 @@ const FilterCheckbox: React.FC<FilterCheckboxProps> = ({
onChange={onChange}
disabled={disabled}
checked={checked}
value={value || ""}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allow a value to be passed in case we want to explicitly have a value set for checkbox submissions on search

Without this it's just { name: "status-forecased", value: "on"}

initialQueryParams,
queryParamKey,
formRef,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More logic was added to useSearchFilter since the SearchFilterAccordion is getting sizeable

onClick={(event) => {
event.preventDefault();
onClearAll?.();
}}
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.

select all/clear all options need to prevent form submit. The actual query param update and form submit happens together in useSearchFilter

@@ -1,21 +1,47 @@
"use client";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The name of this file might be better as useSearchFilterAccordion (if it's not also being used for opportunity status checkboxes - it would need to be refactored a bit for that) - but no pressing need to change the filename

@@ -1,6 +1,6 @@
"use client";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicitly mark all these files as use client so its clear

@rylew1 rylew1 changed the title [Issue #1489] Finish logic for [Issue #1489] Complete search filter accordion logic Mar 18, 2024
Copy link
Collaborator

@andycochran andycochran left a comment

Choose a reason for hiding this comment

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

LGTM, but I'd suggest @acouch give the hooks a look.

frontend/src/hooks/useSearchFormState.ts Show resolved Hide resolved
fundingInstrument: fundingInstrumentQueryParams,
} = requestURLQueryParams;

// TODO: move this to server-side calculation?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that's right; the frontend shouldn't be responsible for this. It seems like the API should return an error if we request something specific from the API that doesn't exist.

@rylew1 rylew1 merged commit fb33b83 into main Mar 18, 2024
9 checks passed
@rylew1 rylew1 deleted the rylew/1489-query-param-for-agency-and-funding-instrument-filters branch March 18, 2024 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Hookup funding instrument and agency to query params
2 participants