-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawer issues with lazy loaded components #36934
Comments
I can reproduce this, though I wonder if it can be reproed without react router 🤔 |
Hello @mj12albert , I updated the sandbox removing react-router, the problem is still present |
This also seems to be the case for |
Any update on this? We are attempting to implement lazy loading in our application and this bug is preventing us from making that change. |
The same issue. Using: |
+1 here :( |
My fix was like this: when clicking an item to not do closeMenu() and navigate(path) in the same render. (you can put one of them in a setTimeout with a small time, but I didn't went like this.) My solution was:
|
I'm experiencing an issue when routing to another page, the drawer closes, but the backdrop remains. If I click twice, it disappears and I don't see the behaviour again unless I do a full page refresh. |
This works fine. const navigate = useNavigate();
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
const handleClick = useCallback((event: MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
}, []);
const handleClose = useCallback((url?: string) => {
setAnchorEl(null);
if (url) setTimeout(() => navigate(url), 300);
}, []); <IconButton
aria-haspopup='true'
aria-expanded={open ? 'true' : undefined}
onClick={handleClick}
color='inherit'
>
<AccountCircle />
</IconButton>
<Menu
anchorEl={anchorEl}
open={open}
onClose={() => handleClose()}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
>
<MenuItem onClick={() => handleClose('/profile')}>
<ListItemIcon>
<Person fontSize='small' />
</ListItemIcon>
<T>Profile</T>
</MenuItem>
<Divider variant='middle' />
<MenuItem onClick={() => handleClose('/logout')}>
<ListItemIcon>
<Logout fontSize='small' />
</ListItemIcon>
<T>Logout</T>
</MenuItem>
</Menu> |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/mui-drawer-with-lazy-components-yyg5n0
Steps:
Current behavior 😯
Sometimes the
Drawer
seems to ignore theopen
prop and stays opened even if set tofalse
.Expected behavior 🤔
The
Drawer
should close if theopen
prop equalstrue
Context 🔦
We use the drawer as a sidebar navigation, each children is a react router
<Link>
pointing to a dedicated<Route>
which will render aReact.lazy
loaded component.The issues is not present using standard component imports.
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: