diff --git a/striker-ui/components/TabContent.tsx b/striker-ui/components/TabContent.tsx index eb5ce0ce..851f6c50 100644 --- a/striker-ui/components/TabContent.tsx +++ b/striker-ui/components/TabContent.tsx @@ -1,21 +1,29 @@ import { Box } from '@mui/material'; -import { ReactElement, useMemo } from 'react'; +import { ReactElement, ReactNode, useMemo } from 'react'; const TabContent = ({ changingTabId, children, + retain = false, tabId, }: TabContentProps): ReactElement => { const isTabIdMatch = useMemo( () => changingTabId === tabId, [changingTabId, tabId], ); - const displayValue = useMemo( - () => (isTabIdMatch ? 'initial' : 'none'), - [isTabIdMatch], + const result = useMemo( + () => + retain ? ( + + {children} + + ) : ( + isTabIdMatch && children + ), + [children, isTabIdMatch, retain], ); - return {children}; + return <>{result}; }; export default TabContent; diff --git a/striker-ui/types/TabContent.d.ts b/striker-ui/types/TabContent.d.ts index ed031541..6ea5f1c9 100644 --- a/striker-ui/types/TabContent.d.ts +++ b/striker-ui/types/TabContent.d.ts @@ -1,4 +1,9 @@ -type TabContentProps = import('react').PropsWithChildren<{ - changingTabId: T; - tabId: T; -}>; +type TabContentOptionalProps = { + retain?: boolean; +}; + +type TabContentProps = TabContentOptionalProps & + import('react').PropsWithChildren<{ + changingTabId: T; + tabId: T; + }>;