diff --git a/ui/src/App.vue b/ui/src/App.vue index 19d15fc..f869b64 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -6,8 +6,11 @@ import AlertDescription from './components/ui/alert/AlertDescription.vue'; import Navbar from './components/Navigation/Navbar.vue'; import { cancelLOA } from './api/loa'; + import { onBeforeUnmount, onMounted, ref } from 'vue'; const userStore = useUserStore(); + const headerRef = ref(null); + let resizeObserver: ResizeObserver | null = null; function formatDate(dateStr) { if (!dateStr) return ""; @@ -22,6 +25,27 @@ const environment = import.meta.env.VITE_ENVIRONMENT; //@ts-ignore const version = import.meta.env.VITE_APPLICATION_VERSION; + + function updateHeaderHeight() { + if (!headerRef.value) return; + const height = headerRef.value.offsetHeight; + document.documentElement.style.setProperty('--app-header-height', `${height}px`); + } + + onMounted(() => { + updateHeaderHeight(); + + // Gracefully skip observer setup for environments that do not support ResizeObserver. + if (typeof ResizeObserver === 'undefined' || !headerRef.value) return; + + resizeObserver = new ResizeObserver(updateHeaderHeight); + resizeObserver.observe(headerRef.value); + }); + + onBeforeUnmount(() => { + resizeObserver?.disconnect(); + }); +