-
Notifications
You must be signed in to change notification settings - Fork 0
feat(website): don't reload the whole page when applying the filters #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(website): don't reload the whole page when applying the filters #985
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements client-side filter application without full page reloads. When users apply filters, the page state is now updated dynamically via React hooks and the URL is modified using the History API, rather than triggering a navigation event.
Key changes:
- Introduced a
usePageStatehook that manages page state in React and syncs it with the URL - Converted filter application from anchor links to button clicks with state updates
- Implemented draft state management in filter selectors to allow modifications before applying
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/components/views/usePageState.ts | New hook that manages page state from URL and updates URL via History API |
| website/src/components/pageStateSelectors/ApplyFilterButton.tsx | Changed from anchor link to button with onClick handler |
| website/src/components/pageStateSelectors/SingleVariantPageStateSelector.tsx | Manages draft state and syncs with parent page state via useEffect |
| website/src/components/pageStateSelectors/CompareVariantsPageStateSelector.tsx | Added draft state management with useEffect synchronization |
| website/src/components/pageStateSelectors/CompareVariantsToBaselineStateSelector.tsx | Added draft state management with useEffect synchronization |
| website/src/components/pageStateSelectors/CompareSideBySidePageStateSelector.tsx | Added draft state management with useEffect synchronization |
| website/src/components/pageStateSelectors/SequencingEffortsPageStateSelector.tsx | Added draft state management with useEffect synchronization |
| website/src/components/pageStateSelectors/wasap/WasapPageStateSelector.tsx | Added setPageState prop to apply filters without reload |
| website/src/components/views/analyzeSingleVariant/CollectionsList.tsx | Changed from link navigation to state updates via setPageState |
| website/src/components/views/analyzeSingleVariant/QuickstartLinks.tsx | Changed from href links to onClick handlers for filter application |
| website/src/components/views/wasap/WasapPage.tsx | Integrated usePageState hook and removed currentUrl prop |
| website/src/components/views/wasap/Wasap.astro | Removed URL prop passing to React component |
| website/src/views/OrganismConstants.ts | Added earliestDate field to OrganismConstants interface |
| website/src/components/genspectrum/GsSequencesByLocation.tsx | Added key prop to force remount when mapName changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
website/src/components/pageStateSelectors/CompareSideBySidePageStateSelector.tsx
Outdated
Show resolved
Hide resolved
website/src/components/pageStateSelectors/CompareSideBySidePageStateSelector.tsx
Outdated
Show resolved
Hide resolved
website/src/components/views/analyzeSingleVariant/CollectionsList.tsx
Outdated
Show resolved
Hide resolved
50de90d to
065e16c
Compare
cb63b36 to
f877413
Compare
fhennig
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a minor docs thing
|
|
||
| import type { PageStateHandler } from '../../views/pageStateHandlers/PageStateHandler.ts'; | ||
|
|
||
| export function usePageState<StateHandler extends PageStateHandler<object>>(pageStateHandler: StateHandler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite central to the whole working of the dashboards now. I like it! I think because it's important, it'd be good to add documentation; it'll help new people find their way around the codebase when we explain some core mechanisms here. Maybe something like this:
Given a
PageStateHandler, this hook initially parses the page state from the current URL. It returns apageStateobject and asetPageStatefunction. When the function is called, the new page state is turned into a URL and set as the current URL (added to the page history). This way, the URL and current page state are kept in sync.
| ); | ||
|
|
||
| const { pageState, setPageState } = usePageState(pageStateHandler); | ||
| const { base, analysis } = pageState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { pageState: { base, analysis }, setPageState } = usePageState(pageStateHandler);
resolves #984
Summary
Screenshot
PR Checklist