Skip to content

Commit

Permalink
Merge pull request #5806 from thornbill/fix-dashboard-class
Browse files Browse the repository at this point in the history
Fix dashboard body class sometimes missing
  • Loading branch information
thornbill authored Jul 18, 2024
2 parents 2d68f94 + 8c06742 commit f3bb9f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/apps/dashboard/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -36,6 +36,15 @@ const AppLayout: FC<AppLayoutProps> = ({
setIsDrawerActive(!isDrawerActive);
}, [ isDrawerActive, setIsDrawerActive ]);

// Update body class
useEffect(() => {
document.body.classList.add('dashboardDocument');

return () => {
document.body.classList.remove('dashboardDocument');
};
}, []);

return (
<Box sx={{ display: 'flex' }}>
<ElevationScroll elevate={false}>
Expand Down
3 changes: 0 additions & 3 deletions src/scripts/libraryMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,23 +581,20 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {

if (isLibraryPage) {
bodyClassList.add('libraryDocument');
bodyClassList.remove('dashboardDocument');
bodyClassList.remove('hideMainDrawer');

if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(true);
}
} else if (isDashboardPage) {
bodyClassList.remove('libraryDocument');
bodyClassList.add('dashboardDocument');
bodyClassList.remove('hideMainDrawer');

if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(true);
}
} else {
bodyClassList.remove('libraryDocument');
bodyClassList.remove('dashboardDocument');
bodyClassList.add('hideMainDrawer');

if (navDrawerInstance) {
Expand Down

0 comments on commit f3bb9f2

Please sign in to comment.