Clear active filter when navigating to All Tasks When a filter was active and the user navigated to /chores
via the navbar, the activeFilterId state persisted even though the filterId
This commit is contained in:
@@ -368,8 +368,6 @@ const MyChores = () => {
|
||||
|
||||
// Read and apply filters from URL parameters
|
||||
useEffect(() => {
|
||||
if (!chores.length || !savedFilters.length) return
|
||||
|
||||
// Check for filterId (camelCase) or filter_id (snake_case) for advanced filters
|
||||
const rawFilterId =
|
||||
searchParams.get('filterId') || searchParams.get('filter_id')
|
||||
@@ -378,6 +376,14 @@ const MyChores = () => {
|
||||
|
||||
const oldFilter = searchParams.get('filter')
|
||||
|
||||
// If filterId is no longer in URL but filter is still active in state, clear it
|
||||
if (!filterId && !oldFilter && activeFilterId) {
|
||||
clearActiveFilter()
|
||||
return
|
||||
}
|
||||
|
||||
if (!chores.length || !savedFilters.length) return
|
||||
|
||||
// Handle advanced filter parameter
|
||||
if (filterId && !activeFilterId) {
|
||||
const filter = savedFilters.find(f => f.id === filterId)
|
||||
@@ -416,6 +422,7 @@ const MyChores = () => {
|
||||
activeFilterId,
|
||||
savedFilters,
|
||||
applyCustomFilter,
|
||||
clearActiveFilter,
|
||||
selectedProject,
|
||||
projectFilteredChores,
|
||||
setSearchFilter,
|
||||
|
||||
Reference in New Issue
Block a user