Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/web/src/contexts/ModulesFilterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface ModulesFilterContextValue extends ModulesFilterState {
setDueAfter: (v: string | null) => void;
setDueBefore: (v: string | null) => void;
updateFilter: (updater: (prev: ModulesFilterState) => Partial<ModulesFilterState>) => void;
/** Reset every filter back to defaults (e.g. when switching projects). */
reset: () => void;
}

const defaultState: ModulesFilterState = {
Expand Down Expand Up @@ -67,6 +69,8 @@ export function ModulesFilterProvider({ children }: { children: ReactNode }) {
[],
);

const reset = useCallback(() => setState(defaultState), []);

const setSearch = useCallback((v: string) => {
setState((prev) => ({ ...prev, search: v }));
}, []);
Expand Down Expand Up @@ -143,6 +147,7 @@ export function ModulesFilterProvider({ children }: { children: ReactNode }) {
setDueAfter,
setDueBefore,
updateFilter,
reset,
}),
[
state,
Expand All @@ -161,6 +166,7 @@ export function ModulesFilterProvider({ children }: { children: ReactNode }) {
setDueAfter,
setDueBefore,
updateFilter,
reset,
],
);

Expand Down
13 changes: 13 additions & 0 deletions apps/web/src/pages/ModulesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,26 @@ function ModuleProgressCircle({ progress }: { progress: number }) {
);
}

// The modules filter provider lives at the app-shell root and outlives this
// page, so its status/lead/member ids (which are project-specific) would carry
// over into another project. Track the project the filter was last set for at
// module scope so it survives remounts, and reset when the project changes.
let lastFilteredProjectId: string | undefined;

export function ModulesPage() {
const { t } = useTranslation();
const { workspaceSlug, projectId } = useParams<{
workspaceSlug: string;
projectId: string;
}>();
const filter = useModulesFilter();
const resetFilter = filter.reset;
useEffect(() => {
if (projectId && projectId !== lastFilteredProjectId) {
lastFilteredProjectId = projectId;
resetFilter();
}
}, [projectId, resetFilter]);
const [workspace, setWorkspace] = useState<WorkspaceApiResponse | null>(null);
const [project, setProject] = useState<ProjectApiResponse | null>(null);
const [modules, setModules] = useState<ModuleApiResponse[]>([]);
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/pages/WorkspaceViewsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ export function WorkspaceViewsPage() {
if (prevViewIdRef.current !== viewId) {
prevViewIdRef.current = viewId;
viewAppliedRef.current = false;
// Static views (all-issues, assigned, etc.) carry no saved filters, so
// clear any left over from a custom view instead of keeping them applied.
if (!isCustomViewId(viewId)) {
setFilters(parseWorkspaceViewFiltersFromSearchParams(new URLSearchParams()));
}
}
if (!workspaceSlug || !viewId || !isCustomViewId(viewId) || viewAppliedRef.current) return;
viewAppliedRef.current = true;
Expand Down
Loading