diff --git a/src/bin/BinYards.tsx b/src/bin/BinYards.tsx index fed79eb..7ef7d1c 100644 --- a/src/bin/BinYards.tsx +++ b/src/bin/BinYards.tsx @@ -211,12 +211,6 @@ export default function BinYard(props: Props) { } }, [props.yards, props.yardPerms]); - // useEffect(() => { - // if (props.tab && binYards.length > 1) { - // setYardFilter(binYards[props.tab - 1].key); - // } - // }, [props.tab, binYards, setYardFilter, loadYards]); - const tabChange = (i: number) => { if (tab === i) return; if (i === binYards.length + 2) return; @@ -687,43 +681,68 @@ export default function BinYard(props: Props) { value={tab} TabIndicatorProps={{ style: { background: "rgba(0,0,0,0)" } }} onChange={(_, newValue) => { - if (+newValue > 0) { + // if (+newValue > 0) { tabChange(newValue); - } - }}> - - {yardsLoading ? : } - {searchSelected && ( - - { - loadYards(e.target.value); - }} - /> + // } + }} + startNode={ + <> + + {yardsLoading ? : } + {searchSelected && ( + + { + loadYards(e.target.value); + }} + /> + + )} - )} - - } - onClick={_e => { - setSearchSelected(true); - }} - /> - { - setShowing("all"); - }} - /> + } + onClick={_e => { + setSearchSelected(true); + }} + /> + { + setShowing("all"); + }} + /> + + } + endNode={ + <> + } + onClick={() => setShowAddYard(true)} + disableTouchRipple={true} + /> + + } + > + {/* { + setShowing("all"); + }} + /> */} {binYards.map((n, index) => ( ))} - } - onClick={() => setShowAddYard(true)} - disableTouchRipple={true} - /> + {/* {grainBags.length > 0 && ( + React.Children.toArray(nodes).flatMap((node, nodeIndex) => { + if (React.isValidElement(node) && (node.type as any) === React.Fragment) { + return React.Children.toArray(node.props.children).map((child, childIndex) => + React.isValidElement(child) + ? React.cloneElement(child, { key: `${prefix}-${nodeIndex}-${childIndex}` }) + : child + ); + } + return React.isValidElement(node) + ? React.cloneElement(node, { key: `${prefix}-${nodeIndex}` }) + : node; + }); + + // Process startTabs + const startTabs = flattenNodes(startNode, "start"); + + // Process endTabs + const endTabs = flattenNodes(endNode, "end"); const enhancedChildren = React.Children.map(children, (child) => { if (React.isValidElement(child) && child.type === Tab) { @@ -21,11 +45,14 @@ export default function DraggableTabs({children, ...tabsProps}: DraggableTabsPro } // Return non-Tab children unchanged return child; - }); + }) || []; + + // Combine all tabs into a single array + const allTabs = [...startTabs, ...enhancedChildren, ...endTabs]; return ( - {enhancedChildren} + {allTabs} ) } \ No newline at end of file