Repository navigation
Persist UI state in the url - #336
Open
paigewilliams wants to merge 2 commits into
Open
paigewilliams wants to merge 2 commits into
paigewilliams wants to merge 2 commits into
Conversation
add tests for searchContext
paigewilliams
requested review from
pollardld and
rhodges
and
a balanced review from Copilot
November 30, 2026 23:05
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Search requests can overwrite newer category selections, Explore submissions duplicate requests and history entries, and Back navigation leaves the input and results out of sync with the URL.
3 open issues
1 file not reviewed
client/package-lock.json: Generated file
What changed in this PR
This PR adds URL-backed search state to the React client, allowing links to preserve submitted queries and selected category filters as part of the React migration.
Changes:
- Reads and writes query and category state through URL parameters.
- Runs searches when the results route mounts and returns no results for an empty category selection.
- Introduces Vitest, Testing Library, and search-context tests.
| File | Description |
|---|---|
client/vitest.config.ts |
Configures jsdom tests separately from the React Router build setup. |
client/tests/searchContext.test.tsx |
Tests URL state, category selection, search submission, and failures. |
client/package.json |
Adds test scripts and testing dependencies. |
client/package-lock.json |
Locks the new testing dependencies and related updates. |
client/app/routes/search.tsx |
Executes a search when the results route mounts. |
client/app/context/searchContext.tsx |
Adds URL-backed filters, query persistence, and empty-selection handling. |
Review effort: Balanced
Comment on lines
+88
to
+92
| const handleSearch = useCallback( | ||
| async (categoriesToSearch: FilterCategories[] = categories) => { | ||
| try { | ||
| const results = await fetchResults(categoriesToSearch, query); | ||
| setResults(results); |
Collaborator
Author
There was a problem hiding this comment.
I don't really think this is necessary. I don't think that we are going to have too many requests while others are pending. I'm hoping the API is fast enough to prevent this.
Comment on lines
+165
to
+168
| useEffect(() => { | ||
| // execute search on initial load | ||
| handleSearch(); | ||
| }, []); |
Comment on lines
+66
to
+69
| const [query, setQuery] = useState<string>( | ||
| () => searchParams.get(FILTER_PARAM) ?? "", | ||
| ); | ||
| const searchedQuery = searchParams.get(FILTER_PARAM) ?? ""; // the executed searched query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


asana task
Tracks the searched query and the checked filters. In the previous implementation we were tracking things like the
items_per_page, which I don't think we need to have in the url search params.items_per_pageis not something user configured, so I decided there was no need to keep that functionality in the react migration.I also started adding client testing infrastructure using Vitest.