⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix: restore board label filters after reload
Tinaf09695239ac
diff --git a/apps/web/src/hooks/use-task-filters-with-labels-support.test.tsx b/apps/web/src/hooks/use-task-filters-with-labels-support.test.tsxnew file mode 100644index 000000000..3dd1ef6a9--- /dev/null+++ b/apps/web/src/hooks/use-task-filters-with-labels-support.test.tsx@@ -0,0 +1,104 @@+import { renderHook, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { useTaskFiltersWithLabelsSupport } from "./use-task-filters-with-labels-support";++describe("useTaskFiltersWithLabelsSupport", () => {+ const storageKey = "kaneo:board-filters:project-1";++ beforeEach(() => {+ window.localStorage.clear();+ });++ afterEach(() => {+ window.localStorage.clear();+ });++ it("restores persisted label filters from storage and matches tasks from project data", async () => {+ window.localStorage.setItem(+ storageKey,+ JSON.stringify({ labels: ["label-bug"] }),+ );++ const project = {+ id: "project-1",+ name: "Project",+ slug: "PROJ",+ icon: null,+ description: null,+ isPublic: false,+ createdAt: "2026-04-16T00:00:00.000Z",+ updatedAt: "2026-04-16T00:00:00.000Z",+ workspaceId: "workspace-1",+ columns: [+ {+ id: "todo",+ name: "Todo",+ isFinal: false,+ tasks: [+ {+ id: "task-1",+ title: "Bug task",+ number: 1,+ description: null,+ status: "todo",+ priority: null,+ startDate: null,+ dueDate: null,+ position: 0,+ createdAt: "2026-04-16T00:00:00.000Z",+ updatedAt: "2026-04-16T00:00:00.000Z",+ userId: null,+ assigneeId: null,+ assigneeName: null,+ assigneeImage: null,+ projectId: "project-1",+ labels: [+ {+ id: "label-bug",+ name: "bug",+ color: "red",+ },+ ],+ externalLinks: [],+ },+ {+ id: "task-2",+ title: "Other task",+ number: 2,+ description: null,+ status: "todo",+ priority: null,+ startDate: null,+ dueDate: null,+ position: 1,+ createdAt: "2026-04-16T00:00:00.000Z",+ updatedAt: "2026-04-16T00:00:00.000Z",+ userId: null,+ assigneeId: null,+ assigneeName: null,+ assigneeImage: null,+ projectId: "project-1",+ labels: [],+ externalLinks: [],+ },+ ],+ },+ ],+ plannedTasks: [],+ archivedTasks: [],+ };++ const { result } = renderHook(() =>+ useTaskFiltersWithLabelsSupport(project, "project-1"),+ );++ await waitFor(() => {+ expect(result.current.filters.labels).toEqual(["label-bug"]);+ });++ expect(result.current.filteredProject?.columns[0]?.tasks).toHaveLength(1);+ expect(result.current.filteredProject?.columns[0]?.tasks[0]?.id).toBe(+ "task-1",+ );+ });+});diff --git a/apps/web/src/hooks/use-task-filters-with-labels-support.ts b/apps/web/src/hooks/use-task-filters-with-labels-support.tsindex 6db603e8b..a0a7b4105 100644--- a/apps/web/src/hooks/use-task-filters-with-labels-support.ts+++ b/apps/web/src/hooks/use-task-filters-with-labels-support.ts@@ -1,4 +1,3 @@-import { useQueryClient } from "@tanstack/react-query";import { addWeeks, endOfWeek, isWithinInterval, startOfWeek } from "date-fns";import { useCallback, useEffect, useMemo, useState } from "react";import type { ProjectWithTasks } from "@/types/project";@@ -45,7 +44,6 @@ export function useTaskFiltersWithLabelsSupport(projectId?: string,textQuery?: string,) {- const queryClient = useQueryClient();const storageKey = projectId ? `kaneo:board-filters:${projectId}` : null;const [filters, setFilters] = useState<BoardFilters>(DEFAULT_FILTERS);@@ -71,18 +69,6 @@ export function useTaskFiltersWithLabelsSupport(window.localStorage.setItem(storageKey, JSON.stringify(filters));}, [filters, storageKey]);- // Helper function to get cached labels for a task- const getTaskLabels = useCallback(- (taskId: string) => {- const queryKey = ["labels", taskId];- const cachedData = queryClient.getQueryData(queryKey) as- | Array<{ id: string; name: string; color: string }>- | undefined;- return cachedData || [];- },- [queryClient],- );-const filterTasks = useCallback((tasks: Task[]): Task[] => {const normalizedTextQuery = textQuery?.trim().toLowerCase();@@ -166,8 +152,7 @@ export function useTaskFiltersWithLabelsSupport(// Label filteringif (filters.labels && filters.labels.length > 0) {- const taskLabels = getTaskLabels(task.id);- const taskLabelIds = taskLabels.map((label) => label.id);+ const taskLabelIds = (task.labels ?? []).map((label) => label.id);// Check if task has at least one of the selected labelsconst hasMatchingLabel = filters.labels.some((labelId) =>@@ -182,7 +167,7 @@ export function useTaskFiltersWithLabelsSupport(return true;});},- [filters, getTaskLabels, textQuery],+ [filters, textQuery],);const filteredProject = useMemo(() => {