Tablist fix (#9216)
This commit is contained in:
@ -9,7 +9,6 @@ import { recordStoreFamilyState } from '@/object-record/record-store/states/reco
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { RightDrawerFooter } from '@/ui/layout/right-drawer/components/RightDrawerFooter';
|
||||
import { ShowPageLeftContainer } from '@/ui/layout/show-page/components/ShowPageLeftContainer';
|
||||
import { ShowPageTabListFromUrlOptionalEffect } from '@/ui/layout/show-page/components/ShowPageTabListFromUrlOptionalEffect';
|
||||
import { SingleTabProps, TabList } from '@/ui/layout/tab/components/TabList';
|
||||
import { useTabList } from '@/ui/layout/tab/hooks/useTabList';
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
@ -126,16 +125,12 @@ export const ShowPageSubContainer = ({
|
||||
)}
|
||||
<StyledShowPageRightContainer isMobile={isMobile}>
|
||||
<StyledTabListContainer shouldDisplay={visibleTabs.length > 1}>
|
||||
<ShowPageTabListFromUrlOptionalEffect
|
||||
isInRightDrawer={isInRightDrawer}
|
||||
componentInstanceId={tabListComponentId}
|
||||
tabListIds={tabs.map((tab) => tab.id)}
|
||||
/>
|
||||
<TabList
|
||||
behaveAsLinks={!isInRightDrawer}
|
||||
loading={loading || isNewViewableRecordLoading}
|
||||
tabListInstanceId={tabListComponentId}
|
||||
tabs={tabs}
|
||||
isInRightDrawer={isInRightDrawer}
|
||||
/>
|
||||
</StyledTabListContainer>
|
||||
{(isMobile || isInRightDrawer) && summaryCard}
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
import { useTabList } from '@/ui/layout/tab/hooks/useTabList';
|
||||
import { useEffect } from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
type ShowPageTabListFromUrlOptionalEffectProps = {
|
||||
componentInstanceId: string;
|
||||
tabListIds: string[];
|
||||
isInRightDrawer: boolean;
|
||||
};
|
||||
|
||||
export const ShowPageTabListFromUrlOptionalEffect = ({
|
||||
componentInstanceId,
|
||||
tabListIds,
|
||||
isInRightDrawer,
|
||||
}: ShowPageTabListFromUrlOptionalEffectProps) => {
|
||||
const location = useLocation();
|
||||
const { activeTabId, setActiveTabId } = useTabList(componentInstanceId);
|
||||
|
||||
const hash = location.hash.replace('#', '');
|
||||
|
||||
useEffect(() => {
|
||||
if (isInRightDrawer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hash === activeTabId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tabListIds.includes(hash)) {
|
||||
setActiveTabId(hash);
|
||||
}
|
||||
}, [hash, activeTabId, setActiveTabId, tabListIds, isInRightDrawer]);
|
||||
|
||||
return <></>;
|
||||
};
|
||||
Reference in New Issue
Block a user