Utilizing MUI for crafting a straightforward dashboard featuring an <AppBar>
, a side <Drawer>
, my component appears as follows:
<>
<AppBar>
// code omitted
<AppBar/>
<Drawer>
// code omitted
<Drawer/>
// along with a wrapper for the Outlet
<Stack alignItems={'flex-end'} id="router-outlet-wrapper">
<Toolbar />
<Box sx={{
width: `${menuOpen ? `calc( 100% - ${drawerWidth}px )` : '100%'}`,
height: "100px",
backgroundColor: 'blue'
}}>
Dynamic width div
<Outlet />
</Box>
</Stack>
</>
Upon examining the code, it was discovered that the Outlet
correctly renders the div but is positioned outside its parent container. Furthermore, unlike its parent (the blue box), it fails to adjust its width dynamically based on the Drawer's state.
Evidently, it seems hidden behind the Drawer
(possibly due to a higher z-index
). Take a look at the images below for clarification:
Opened view: https://i.sstatic.net/a6MRs.png
Closed view: https://i.sstatic.net/ibvLD.png
The div
housing the text "la page profile" represents the Outlet
element in this scenario.
The objective is for it to stretch across the entire page width when the drawer is closed and shrink when open. Currently seeking assistance on this matter.
EDIT 1 :
Below is the minimal-reproducible-example:
https://codesandbox.io/s/outlet-error-mre-zqsk55?file=/src/App.js