Skip to content

fix: preserve active task category filters in URL query parameters#1151

Open
anshull-saxena wants to merge 2 commits into
aryandas2911:mainfrom
anshull-saxena:main
Open

fix: preserve active task category filters in URL query parameters#1151
anshull-saxena wants to merge 2 commits into
aryandas2911:mainfrom
anshull-saxena:main

Conversation

@anshull-saxena
Copy link
Copy Markdown

Closes #1084

Changes:

  • Replaced useState(selectedCategories) with useSearchParams from react-router-dom
  • Reads initial filter state from ?categories=Work,Personal query param on mount
  • Updates URL params on category pill click so filters persist across page reloads
  • Clears query params when "Clear all" is clicked

Testing:

  • npm run build passes clean
  • Filters now survive page refresh and navigation
  • URLs like /tasks?categories=Homework,Creative are shareable

- Replace useState(selectedCategories) with useSearchParams from react-router-dom
- Read initial filter state from ?categories= query param on mount
- Update URL params on category pill click to persist across reloads
- Clear query params when 'Clear all' is clicked

Closes aryandas2911#1084
Copilot AI review requested due to automatic review settings May 24, 2026 18:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR persists the “Filter by Category” state in the URL query string so category selections survive refresh/share/back-forward navigation.

Changes:

  • Switch from local selectedCategories state to deriving it from useSearchParams().
  • Update category toggling and “Clear all” to write to the categories query param.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const next = selectedCategories.includes(categoryName)
? selectedCategories.filter((cat) => cat !== categoryName)
: [...selectedCategories, categoryName];
setSearchParams(next.length > 0 ? { categories: next.join(",") } : {});
{selectedCategories.length > 0 && (
<button
onClick={() => setSelectedCategories([])}
onClick={() => setSearchParams({})}
- Create reusable ToastContext with framer-motion animated toasts
- Wrap app with ToastProvider in App.jsx
- Replace all alert() calls with toast notifications across:
  - useTasks.js (create/update/delete/bulk CRUD feedback)
  - Tasks.jsx (duration validation)
  - RoutineBuilder.jsx (save/delete/export/add task)
  - RoutineCard.jsx (start/stop/delete, remove inline toast divs)
  - Dashboard.jsx (duplicate routine)
  - TaskFormModal.jsx (date validation)
  - Analytics.jsx (export feedback)
  - Profile.jsx (name/password updates)

Closes aryandas2911#1082
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.

[Enhancement] Preserve active task category filters in URL query parameters

2 participants