From 9c18ddfc8f7e88ee87476ae53ee6ced2e5f4e55e Mon Sep 17 00:00:00 2001 From: "soroush.asadi" Date: Tue, 16 Jun 2026 21:15:23 +0330 Subject: [PATCH] Fix: board remembers the selected team across refresh The board's selected team was local state that defaulted to the first team on every load, so a refresh snapped away from the team you were on (and its tasks appeared to vanish). Now the selection is restored from localStorage, validated against the current teams, and persisted on change. Co-Authored-By: Claude Opus 4.8 --- client/src/pages/BoardPage.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/pages/BoardPage.tsx b/client/src/pages/BoardPage.tsx index 130a042..5080f34 100644 --- a/client/src/pages/BoardPage.tsx +++ b/client/src/pages/BoardPage.tsx @@ -73,7 +73,8 @@ export function BoardPage() { const [orgName, setOrgName] = useState('') const [teams, setTeams] = useState([]) - const [teamId, setTeamId] = useState(null) + // Remember the selected team across refreshes (it used to snap back to the first team). + const [teamId, setTeamId] = useState(() => localStorage.getItem('teamup.board.team')) const [board, setBoard] = useState(null) const [newTeam, setNewTeam] = useState('') const [newTask, setNewTask] = useState('') @@ -90,7 +91,10 @@ export function BoardPage() { try { const result = await api.get(`/api/orgboard/teams?organizationId=${organizationId}`) setTeams(result) - setTeamId((current) => current ?? result[0]?.id ?? null) + // Keep the current/remembered team if it still exists; otherwise fall back to the first. + setTeamId((current) => + current && result.some((team) => team.id === current) ? current : result[0]?.id ?? null, + ) } catch (err) { toast.error((err as Error).message) } @@ -112,6 +116,11 @@ export function BoardPage() { if (teamId) void loadBoard(teamId) }, [teamId, loadBoard]) + // Persist the selected team so a refresh stays on it. + useEffect(() => { + if (teamId) localStorage.setItem('teamup.board.team', teamId) + }, [teamId]) + async function run(action: () => Promise) { try { await action()