From 7a1b1828e9499768e318205f43965ee8ac80875c Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Sat, 30 Mar 2024 20:11:03 -0300 Subject: [PATCH] Fix tab selection logic in IOModal component --- src/frontend/src/modals/IOModal/index.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index fdd074d2b..a36d51fb0 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -51,25 +51,25 @@ export default function IOModal({ ); const haveChat = chatInput || chatOutput; const [selectedTab, setSelectedTab] = useState( - inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0 + outputs.length > 0 ? 2 : inputs.length > 0 ? 1 : 0 ); - function startView(){ - if(!chatInput && !chatOutput){ - if(outputs.length > 0){ + function startView() { + if (!chatInput && !chatOutput) { + if (outputs.length > 0) { return outputs[0]; } - else{ + else { return inputs[0]; } } - else{ + else { return undefined } } const [selectedViewField, setSelectedViewField] = useState< - { type: string; id: string }|undefined + { type: string; id: string } | undefined >(startView()); const buildFlow = useFlowStore((state) => state.buildFlow); @@ -116,7 +116,7 @@ export default function IOModal({ useEffect(() => { setSelectedViewField(startView()); - setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); + setSelectedTab(outputs.length > 0 ? 2 : inputs.length > 0 ? 1 : 0); }, [inputs.length, outputs.length]); return ( @@ -316,7 +316,7 @@ export default function IOModal({ )} >
- {( haveChat &&