feat(collections): persist filter and tag state in URL#1322
Merged
Conversation
Implements CollectionsOverviewPageStateHandler following the existing
PageStateHandler pattern, and wires it into CollectionsOverview via
usePageState so that filter and tag selections are reflected in the URL
and survive page refreshes and back/forward navigation.
URL format: ?filter=official&tag=ebola&tag=mpox
Default filter ('community') and empty tag list produce a clean URL with
no search params.
Closes #1302
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Replaces the string union type + array with the codebase's standard const-object pattern (CollectionFilters.community etc.), matching how Organisms, EvaluationIntervals, and similar enums are defined. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
usePageState reads window.location.href during initialisation, which fails when Astro SSR-renders the component. Switching from client:load to client:only='react' skips the server render entirely, matching the pattern used by other pages that rely on usePageState. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
usePageState initialises from window.location.href, so URL state left behind by one test (e.g. ?tag=europe&) bleeds into the next — causing TagInput to start with non-empty tags and render an empty placeholder instead of the full one, making getByPlaceholder time out. A beforeEach that resets the URL to '/' ensures each test starts clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds URL-synchronized state for the Collections overview page so the selected “filter” and “tag” values persist across refresh and back/forward navigation, following the existing PageStateHandler + usePageState pattern used elsewhere in the website frontend.
Changes:
- Introduces
CollectionsOverviewPageStateHandlerto parse/serialize{ filter, tagFilter }to/from URL query params. - Wires
CollectionsOverviewto useusePageStateinstead of local React state for filter/tag selection. - Updates the Astro page to render the overview as
client:only='react'and adjusts the browser test setup to reset URL state between tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/views/pageStateHandlers/CollectionsOverviewPageStateHandler.ts | New page-state handler for collections overview URL parsing/serialization. |
| website/src/views/pageStateHandlers/CollectionsOverviewPageStateHandler.spec.ts | Unit tests for the new page-state handler behavior. |
| website/src/pages/collections/[pathFragment]/index.astro | Switches collections overview hydration mode to client-only React. |
| website/src/components/collections/overview/CollectionsOverview.tsx | Replaces local state with URL-synced state via usePageState. |
| website/src/components/collections/overview/CollectionsOverview.browser.spec.tsx | Resets window.history before each test to avoid state leakage. |
…or for filter validation Avoids prototype chain traversal when validating URL filter params. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Pushed the fix, now just waiting for tests to pass again. |
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.
Closes #1302
Summary
Implements CollectionsOverviewPageStateHandler following the existing PageStateHandler pattern, and wires it into CollectionsOverview via usePageState so that filter and tag selections are reflected in the URL and survive page refreshes and back/forward navigation.
URL format:
?filter=official&tag=ebola&tag=mpoxDefault filter ('community') and empty tag list produce a clean URL with no search params.
Screenshot
Screen.Recording.2026-07-08.at.14.45.53.mov
PR Checklist