Skip to content

feat(collections): persist filter and tag state in URL#1322

Merged
fhennig merged 7 commits into
mainfrom
collections-overview-url-state
Jul 13, 2026
Merged

feat(collections): persist filter and tag state in URL#1322
fhennig merged 7 commits into
mainfrom
collections-overview-url-state

Conversation

@fhennig

@fhennig fhennig commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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=mpox

Default 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

  • All necessary documentation has been adapted.
  • The implemented feature is covered by an appropriate test.

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>
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboards Ready Ready Preview, Comment Jul 13, 2026 10:10am

Request Review

Felix Hennig and others added 2 commits July 8, 2026 14:19
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>
@fhennig fhennig marked this pull request as ready for review July 8, 2026 12:32
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 CollectionsOverviewPageStateHandler to parse/serialize { filter, tagFilter } to/from URL query params.
  • Wires CollectionsOverview to use usePageState instead 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.

@fengelniederhammer fengelniederhammer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice :)

…or for filter validation

Avoids prototype chain traversal when validating URL filter params.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@fhennig

fhennig commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Pushed the fix, now just waiting for tests to pass again.

@fhennig fhennig merged commit c52ade8 into main Jul 13, 2026
11 checks passed
@fhennig fhennig deleted the collections-overview-url-state branch July 13, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

collections overview: make filters part of the URL

3 participants