From a088b2da1dbe216ec57728c7ce0eca42773510b7 Mon Sep 17 00:00:00 2001 From: espenkalle Date: Fri, 2 Feb 2024 11:11:48 +0100 Subject: [PATCH] fix(garden): :bug: added condition for rendering of viewsettings Dont render viewsettings before virtual garden is init. this prevents the sidebar from moving around --- packages/garden/src/lib/components/Garden.tsx | 14 +++++--------- .../VirtualContainer/VirtualContainer.tsx | 15 +++++++++++---- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/packages/garden/src/lib/components/Garden.tsx b/packages/garden/src/lib/components/Garden.tsx index 94e12c6e9..d67ba9ada 100644 --- a/packages/garden/src/lib/components/Garden.tsx +++ b/packages/garden/src/lib/components/Garden.tsx @@ -76,7 +76,7 @@ export function Garden, TContext = un }: GardenProps): JSX.Element | null { const client = useRef(new QueryClient()); const [groupingKeys, setGroupingKeys] = useState(initialGrouping); - + const [isLoading, setIsLoading] = useState(true); const [timeInterval, updateTimeInterval] = useState(initialTimeInterval ?? null); const onChangetimeInterval = (timeInterval: string | null) => { updateTimeInterval(timeInterval); @@ -116,12 +116,8 @@ export function Garden, TContext = un customViews={customViews} visuals={visuals} > - - - - { - // Hides ViewSettings sidebar when sidesheet is open - selected ? null : ( + + {selected || isLoading ? null : ( , TContext = un onChangeTimeInterval={onChangetimeInterval} setGroupingKeys={setGroupingKeys} /> - ) - } + )} + diff --git a/packages/garden/src/lib/components/VirtualContainer/VirtualContainer.tsx b/packages/garden/src/lib/components/VirtualContainer/VirtualContainer.tsx index 2df885df2..0c2f0540a 100644 --- a/packages/garden/src/lib/components/VirtualContainer/VirtualContainer.tsx +++ b/packages/garden/src/lib/components/VirtualContainer/VirtualContainer.tsx @@ -1,24 +1,27 @@ +import { Icon } from '@equinor/eds-core-react'; +import { info_circle } from '@equinor/eds-icons'; +import { useEffect } from 'react'; +import styled from 'styled-components'; import { useItemWidths } from '../../hooks'; import { useGarden } from '../../hooks/useGarden'; import { useGardenConfig } from '../../hooks/useGardenConfig'; import { ExpandProvider } from '../ExpandProvider'; import { GardenDataSource } from '../Garden'; import { VirtualGarden } from '../VirtualGarden'; -import { StyledVirtualContainer } from './virtualContainer.styles'; -import { info_circle } from '@equinor/eds-icons'; -import { Icon } from '@equinor/eds-core-react'; -import styled from 'styled-components'; import { SplashScreen } from '../splashScreen/SplashScreen'; +import { StyledVirtualContainer } from './virtualContainer.styles'; Icon.add({ info_circle }); type VirtualContainerProps = { dataSource: GardenDataSource; context: TContext; + setIsLoading: (isLoading: boolean) => void; }; export const VirtualContainer = ({ dataSource, context, + setIsLoading, }: VirtualContainerProps): JSX.Element | null => { const { onClickItem } = useGardenConfig(); const { gardenMetaQuery } = useGarden(); @@ -27,6 +30,10 @@ export const VirtualContainer = ({ return ; } + useEffect(() => { + if (!gardenMetaQuery.isLoading) setIsLoading(false); + }, [gardenMetaQuery.isLoading]); + if (!gardenMetaQuery.data) { // Will never happen when suspense is true throw new Error();