diff --git a/src/frontend/src/pages/MainPage/pages/homePage/index.tsx b/src/frontend/src/pages/MainPage/pages/homePage/index.tsx index 41b0f887e..6d7966b12 100644 --- a/src/frontend/src/pages/MainPage/pages/homePage/index.tsx +++ b/src/frontend/src/pages/MainPage/pages/homePage/index.tsx @@ -111,7 +111,16 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => { flow.is_component === (flowType === "components"), ) === undefined ) { - setFlowType(flowType === "flows" ? "components" : "flows"); + const otherTabHasItems = + flows?.find( + (flow) => + flow.folder_id === (folderId ?? myCollectionId) && + flow.is_component === (flowType === "flows"), + ) !== undefined; + + if (otherTabHasItems) { + setFlowType(flowType === "flows" ? "components" : "flows"); + } } }, [isEmptyFolder]); @@ -222,7 +231,7 @@ const HomePage = ({ type }: { type: "flows" | "components" | "mcp" }) => { setSelectedFlows((old) => old.filter((id) => data.flows.some((flow) => flow.id === id)), ); - }, [data.flows]); + }, [folderData?.flows?.items]); // Reset key states when navigating away useEffect(() => {