From 8c06742d2df5ff6a904740f2c3500d69bb5ff0d8 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 18 Jul 2024 11:42:56 -0400 Subject: [PATCH] Fix dashboard body class sometimes missing --- src/apps/dashboard/AppLayout.tsx | 11 ++++++++++- src/scripts/libraryMenu.js | 3 --- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/apps/dashboard/AppLayout.tsx b/src/apps/dashboard/AppLayout.tsx index ff47e53cc6..2bc5859fd9 100644 --- a/src/apps/dashboard/AppLayout.tsx +++ b/src/apps/dashboard/AppLayout.tsx @@ -2,7 +2,7 @@ import AppBar from '@mui/material/AppBar'; import Box from '@mui/material/Box'; import { type Theme } from '@mui/material/styles'; import useMediaQuery from '@mui/material/useMediaQuery'; -import React, { FC, useCallback, useState } from 'react'; +import React, { FC, useCallback, useEffect, useState } from 'react'; import { Outlet, useLocation } from 'react-router-dom'; import AppBody from 'components/AppBody'; @@ -36,6 +36,15 @@ const AppLayout: FC = ({ setIsDrawerActive(!isDrawerActive); }, [ isDrawerActive, setIsDrawerActive ]); + // Update body class + useEffect(() => { + document.body.classList.add('dashboardDocument'); + + return () => { + document.body.classList.remove('dashboardDocument'); + }; + }, []); + return ( diff --git a/src/scripts/libraryMenu.js b/src/scripts/libraryMenu.js index dfb26fbaf1..cca10eab56 100644 --- a/src/scripts/libraryMenu.js +++ b/src/scripts/libraryMenu.js @@ -581,7 +581,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) { if (isLibraryPage) { bodyClassList.add('libraryDocument'); - bodyClassList.remove('dashboardDocument'); bodyClassList.remove('hideMainDrawer'); if (navDrawerInstance) { @@ -589,7 +588,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) { } } else if (isDashboardPage) { bodyClassList.remove('libraryDocument'); - bodyClassList.add('dashboardDocument'); bodyClassList.remove('hideMainDrawer'); if (navDrawerInstance) { @@ -597,7 +595,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) { } } else { bodyClassList.remove('libraryDocument'); - bodyClassList.remove('dashboardDocument'); bodyClassList.add('hideMainDrawer'); if (navDrawerInstance) {