Repository navigation
feat(ngos): keep the explorer sort in the URL - #348
Merged
Merged
Conversation
|
@chidii is attempting to deploy a commit to the Ashborne team Team on Vercel. A member of the Team first needs to authorize it. |
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
Search (
q) and page (page) were already synced to the URL on the NGO explorer, but the selected sort was local-only state. Sharing a link or pressing back/forward lost the sort. This syncssortto the query string and restores it on load, matching the existingq/pagebehaviour.Closes #310
Changes
src/components/ngos/NgoExplorer.tsxparseSort()with aSORT_OPTIONSallowlist; unknown/missing values fall back to'newest'.sortBynow initialises fromsearchParams.get('sort')instead of hard-coding'newest'.qandpage) now restoressorttoo, so back/forward navigation works.syncParams()acceptssortand writes it to the URL (clears it when the default'newest'is selected, to keep shared links tidy — same pattern used forpage=1).handleSortChange()persists the new sort and resets to page 1.src/components/ngos/NgoExplorer.test.tsx<select>value and that the list is actually ordered by active streams desc).page.Acceptance criteria
Testing
Ran the same steps as
.github/workflows/ci.ymllocally:npm run lint— passnpm run typecheck— passnpm test— pass (2 new tests included)npm run build— passManually verified:
?sort=most-active-streamson load selects that option and orders cards accordingly; changing the sort while on?q=…&page=2produces?q=…&sort=…(page reset to 1); back/forward restores the sort.Notes
page.tsx; the existing<Suspense>boundary already coversuseSearchParams().'newest'is omitted from the URL so existing links stay unchanged; only non-default sorts add?sort=….