mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #5806 from thornbill/fix-dashboard-class
Fix dashboard body class sometimes missing
This commit is contained in:
commit
f3bb9f2eef
2 changed files with 10 additions and 4 deletions
|
@ -2,7 +2,7 @@ import AppBar from '@mui/material/AppBar';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import { type Theme } from '@mui/material/styles';
|
import { type Theme } from '@mui/material/styles';
|
||||||
import useMediaQuery from '@mui/material/useMediaQuery';
|
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 { Outlet, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import AppBody from 'components/AppBody';
|
import AppBody from 'components/AppBody';
|
||||||
|
@ -36,6 +36,15 @@ const AppLayout: FC<AppLayoutProps> = ({
|
||||||
setIsDrawerActive(!isDrawerActive);
|
setIsDrawerActive(!isDrawerActive);
|
||||||
}, [ isDrawerActive, setIsDrawerActive ]);
|
}, [ isDrawerActive, setIsDrawerActive ]);
|
||||||
|
|
||||||
|
// Update body class
|
||||||
|
useEffect(() => {
|
||||||
|
document.body.classList.add('dashboardDocument');
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.body.classList.remove('dashboardDocument');
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex' }}>
|
<Box sx={{ display: 'flex' }}>
|
||||||
<ElevationScroll elevate={false}>
|
<ElevationScroll elevate={false}>
|
||||||
|
|
|
@ -581,7 +581,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
||||||
|
|
||||||
if (isLibraryPage) {
|
if (isLibraryPage) {
|
||||||
bodyClassList.add('libraryDocument');
|
bodyClassList.add('libraryDocument');
|
||||||
bodyClassList.remove('dashboardDocument');
|
|
||||||
bodyClassList.remove('hideMainDrawer');
|
bodyClassList.remove('hideMainDrawer');
|
||||||
|
|
||||||
if (navDrawerInstance) {
|
if (navDrawerInstance) {
|
||||||
|
@ -589,7 +588,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
||||||
}
|
}
|
||||||
} else if (isDashboardPage) {
|
} else if (isDashboardPage) {
|
||||||
bodyClassList.remove('libraryDocument');
|
bodyClassList.remove('libraryDocument');
|
||||||
bodyClassList.add('dashboardDocument');
|
|
||||||
bodyClassList.remove('hideMainDrawer');
|
bodyClassList.remove('hideMainDrawer');
|
||||||
|
|
||||||
if (navDrawerInstance) {
|
if (navDrawerInstance) {
|
||||||
|
@ -597,7 +595,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bodyClassList.remove('libraryDocument');
|
bodyClassList.remove('libraryDocument');
|
||||||
bodyClassList.remove('dashboardDocument');
|
|
||||||
bodyClassList.add('hideMainDrawer');
|
bodyClassList.add('hideMainDrawer');
|
||||||
|
|
||||||
if (navDrawerInstance) {
|
if (navDrawerInstance) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue