From 70eeab2d7270acb10d507ea18bb8446752ef97fe Mon Sep 17 00:00:00 2001 From: Nitheesh T Ganesh Date: Fri, 2 Aug 2024 15:57:55 -0600 Subject: [PATCH] content height dynamically calculated using app bar height --- .../src/components/Shared/EAOAppBar.tsx | 11 +++++++--- compliance-web/src/routes/__root.tsx | 20 +++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/compliance-web/src/components/Shared/EAOAppBar.tsx b/compliance-web/src/components/Shared/EAOAppBar.tsx index 7403897d..bd510b59 100644 --- a/compliance-web/src/components/Shared/EAOAppBar.tsx +++ b/compliance-web/src/components/Shared/EAOAppBar.tsx @@ -14,7 +14,10 @@ import AccountCircleIcon from "@mui/icons-material/AccountCircle"; import { AppConfig } from "@/utils/config"; import { useAuth } from "react-oidc-context"; import EnvironmentBanner from "./EnvironmentBanner"; +import { forwardRef, HTMLProps } from "react"; + +type EAOAppBarProps = HTMLProps; interface AppBarProps extends MuiAppBarProps { open?: boolean; } @@ -28,12 +31,12 @@ const AppBar = styled(MuiAppBar, { }), })); -export default function EAOAppBar() { +const EAOAppBar = forwardRef((_props, ref) => { const theme = useTheme(); const auth = useAuth(); return ( <> - + ); -} +}); + +export default EAOAppBar; diff --git a/compliance-web/src/routes/__root.tsx b/compliance-web/src/routes/__root.tsx index 8edb1fb1..adf3e7c0 100644 --- a/compliance-web/src/routes/__root.tsx +++ b/compliance-web/src/routes/__root.tsx @@ -4,6 +4,7 @@ import SideNavBar from "@/components/Shared/SideNav/SideNavBar"; import { Box } from "@mui/system"; import { createRootRouteWithContext, Outlet } from "@tanstack/react-router"; import { TanStackRouterDevtools } from "@tanstack/router-devtools"; +import { useState, useRef, useEffect } from "react"; import { AuthContextProps } from "react-oidc-context"; type RouterContext = { @@ -16,10 +17,25 @@ export const Route = createRootRouteWithContext()({ }); function Layout() { + const [headerHeight, setHeaderHeight] = useState(0); + const appBarRef = useRef(null); + + useEffect(() => { + if (appBarRef.current) { + setHeaderHeight(appBarRef.current.offsetHeight); + } + }, []); + return ( <> - - + +