From aae9c99fefd6d2627b044896c32915d81d86d05a Mon Sep 17 00:00:00 2001 From: shivam-kumar Date: Tue, 2 Sep 2025 16:15:19 +0530 Subject: [PATCH] SCAL-213939 Update document body width to account for sidebar space --- src/components/DevDocTemplate/index.tsx | 6 +++++- src/components/LeftSidebar/index.tsx | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/DevDocTemplate/index.tsx b/src/components/DevDocTemplate/index.tsx index b74626fe5..c7cf03cd9 100644 --- a/src/components/DevDocTemplate/index.tsx +++ b/src/components/DevDocTemplate/index.tsx @@ -63,7 +63,11 @@ const DevDocTemplate: FC = (props) => { const isHomePage = curPageNode?.pageAttributes?.pageid === HOME_PAGE_ID; - const { width, ref } = useResizeDetector(); + // use window.innerWidth if window is defined else use useResizeDetector width + const { + width = isBrowser() ? window?.innerWidth : 0, + ref, + } = useResizeDetector(); const [params, setParams] = useState({ [TS_HOST_PARAM]: DEFAULT_HOST, [TS_ORIGIN_PARAM]: '', diff --git a/src/components/LeftSidebar/index.tsx b/src/components/LeftSidebar/index.tsx index 8bbcce42c..531b733d9 100644 --- a/src/components/LeftSidebar/index.tsx +++ b/src/components/LeftSidebar/index.tsx @@ -71,7 +71,9 @@ const LeftSideBar = (props: { }, [params[NAV_PREFIX], params[TS_PAGE_ID_PARAM], props.navContent]); useEffect(() => { - props.handleLeftNavChange(ref?.current?.offsetWidth); + if (ref?.current?.offsetWidth) { + props.handleLeftNavChange(ref?.current?.offsetWidth); + } }, [width]); const toggleExpandOnTab = (text: string) => {