diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index 0278f92..2a3c650 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -1,5 +1,6 @@ import CssBaseline from '@mui/material/CssBaseline' import { ThemeProvider } from '@mui/material/styles' +import Box from '@mui/material/Box' import Head from 'next/head' import { useRouter } from 'next/router' import PropTypes from 'prop-types' @@ -18,6 +19,7 @@ export default function MyApp(props) { const { Component, pageProps } = props const route = useRouter() const [darkMode, setDarkMode] = useState(false) + const [scrollNeeded, setScrollNeeded] = useState(false) useEffect(() => { const jssStyles = document.querySelector('#jss-server-side') @@ -29,8 +31,22 @@ export default function MyApp(props) { if (darkModePreference) { setDarkMode(darkModePreference === '1') } + + handleScroll() }, []) + useEffect(() => { + handleScroll() + }, [route.pathname]) + + const handleScroll = () => { + const contentHeight = document.body.scrollHeight + const windowHeight = window.innerHeight + const hasVerticalScrollbar = contentHeight > windowHeight + + setScrollNeeded(hasVerticalScrollbar) + } + return ( <>
@@ -43,12 +59,13 @@ export default function MyApp(props) {