diff --git a/artifacts/tx-os/src/pages/notes.tsx b/artifacts/tx-os/src/pages/notes.tsx index c58fda79..35a94c2a 100644 --- a/artifacts/tx-os/src/pages/notes.tsx +++ b/artifacts/tx-os/src/pages/notes.tsx @@ -137,6 +137,16 @@ export default function NotesPage() { const { data: folders = [] } = useNoteFolders(view === "archived"); const moveNote = useMoveNoteToFolder(); const showFolders = view === "active" || view === "archived"; + + // If the user switches tabs (or a folder is deleted) such that the current + // selection no longer exists in this view's folder set, fall back to "all" + // so they don't get stuck on an empty list. + useEffect(() => { + if (folderSelection.kind !== "folder") return; + if (!folders.some((f) => f.id === folderSelection.id)) { + setFolderSelection({ kind: "all" }); + } + }, [folders, folderSelection]); const { data: receivedNotes = [], isLoading: loadingReceived } = useReceivedNotes(false); const { data: archivedReceivedNotes = [], isLoading: loadingArchivedReceived } =