fix(frontend): replace path params with query params for search#28
Open
tkitsunai wants to merge 1 commit into
Open
fix(frontend): replace path params with query params for search#28tkitsunai wants to merge 1 commit into
tkitsunai wants to merge 1 commit into
Conversation
Empty search strings hit an ambiguity in the path-param route (/search/:search_string/:exact?): they either fell through to the Legend page, or (with exact) collapsed to /search/exact and got misread as searching for the literal string "exact". Move to query params instead: - App.tsx: route becomes /search (no params) - NavBar.tsx: search handlers now go through a new useSearchNavigation() hook instead of calling useNavigate() directly - hooks/useSearchNavigation.ts (new): buildSearchPath(searchQuery, exact) is a pure function building the query-param path; the hook itself just calls navigate() with it - Search.tsx: useParams -> useSearchParams, reading q/exact from the query string Fixes nemasu#27
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.
Summary
Fixes ambiguous search routing per #27 — an empty search string used to
either fall through to the Legend page or get misread as
exactsearch,because both were encoded as positional path segments.
App.tsx: route/search/:search_string/:exact?→/search(no params)NavBar.tsx: the three search handlers now go through a newuseSearchNavigation()hook instead of callinguseNavigate()directlyhooks/useSearchNavigation.ts(new):buildSearchPath(searchQuery, exact)is a pure function that builds the query-param path; the hook itself is a
thin wrapper that just calls
navigate()with itSearch.tsx:useParams→useSearchParams, readingq/exactfrom thequery string instead of path segments
Test plan
buildSearchPath: normal string,exact=true, emptystring + exact (the original bug case), special characters (spaces,
slashes, multibyte), and a regression test for a literal
"exact"search string no longer being mistaken for the exact flag
npm run typecheck— no errorsnpm run check(biome) — no errorssearch, symbol search (
/etc.)Fixes #27