-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Modal] Scrollbar and padding issue #10000
Comments
@lorensr Do you have a reproduction example? It's a well-known limitation of disabling the scrollbar. We handle absolute positioned elements that have the |
FYI, another thing I've found is that the box-sizing: content-box; |
Thanks, adding the class worked. I didn't need It should also be noted that when the scroll bar is removed, the block header inside my Fixed by changing main {
position: absolute;
box-sizing: border-box;
left: 0;
right: -20px;
overflow-x: hidden;
} The downside is that when the scrollbar is present, centered children are now 10 pixels to the right of center, and I have to hide overflow. |
I had a similar issue, but the container was not absolute. What fixed it for me was adding
|
I'm not 100% sure if this is the correct way to do it but i added the following css properties to the body {
position: absolute;
left: -17px;
right: -17px;
padding-top: 0;
padding-right: 17px;
padding-left: 17px;
padding-bottom: 0px;
overflow-x: hidden;
overflow-y: auto !important //Remove the !important if you want the scroll bar to disappear
} |
Hopefully this helps someone else: After trying some various css overrides that seemed to work but felt wrong, such as @chrisshaddad's, I found we were getting shifting due to previously forcing Instead of placing a bunch of extra For reference our DOM looks like:
and the CSS (our header's height is 45px):
|
Hello, I currently have this same problem and I must admit that I cannot find my happiness in any of the solutions mentioned. From what I understood, Thinking about the problem and the solutions you mentioned, I was wondering why it would not be possible for Material-UI to implement a scrollable property for everything related to If this is not possible, maybe implement a I suspect that this is easier said than done. I would therefore like to thank you for the exceptional work you are doing. |
FWIW I just set a global |
@avdd This does not help since it will allow you to scroll in the body and not in the modal. |
@rememberYou The modal is a low level primitive, you might want to use the dialog instead: https://material-ui.com/demos/dialogs/#scrolling-long-content. |
@rememberYou ModalManager sets |
@oliviertassinari thank you for the solution. |
@lorensr Is this still an issue? |
@oliviertassinari One last thing, I tried with the The issue is that I have a In this case, do I have to use the |
@nathanmarks yes, looks like modal components docs pages still don't mention |
Using 3.5.1 - the Dialog shifts to the left before closing. Reproducible here https://material-ui.com/demos/dialogs/ - open and close the Simple Dialog demo. After testing, this started in v3.3. |
@stephen099 Thank you for reporting! I confirm, but it's a different issue. |
I've noticed that on the header (with the latest mui), the I'm wondering, why is this 'add padding' happening in the first place, why is it needed? For me it's broken by the How do I prevent this from happening without having to override the css styling with |
I'm witnessing this in use of |
@WholemealDrop Follow #17353. |
@oliviertassinari ahah apparently my search skills aren't that great. Thank you! |
@oliviertassinari I have managed to reduce the problem to the core. The issue seems to be that somehow there is incorrect calculations when display: flex + minHeight: 100vh + body no padding and margin is combined. It seems like that the code expects to be a scrollbar there but in fact there is not. This code should reproduce the issue. import React, {FunctionComponent, SyntheticEvent, useState} from 'react';
import {IconButton, Menu, MenuItem, Tooltip} from "@material-ui/core";
import TranslateIcon from "@material-ui/icons/Translate";
import MuiAppBar from "@material-ui/core/AppBar";
import Toolbar from "@material-ui/core/Toolbar";
const AdminAppContainer: FunctionComponent = () => {
const handleMenu = (event: SyntheticEvent) => setAnchorEl(event.currentTarget);
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
const open = Boolean(anchorEl);
const handleClose = () => setAnchorEl(null);
const body = document.getElementsByTagName('body')[0];
body.style.margin = "0";
body.style.padding = "0";
return (
<div style={{ display: 'flex', minHeight: '100vh'}}>
<MuiAppBar color="secondary" >
<Toolbar>
<div style={{flex: 1}}></div>
<div>
<Tooltip title='asd'>
<IconButton onClick={handleMenu}><TranslateIcon /></IconButton>
</Tooltip>
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
<MenuItem key={'test'} onClick={handleClose}>Test</MenuItem>
</Menu>
</div>
</Toolbar>
</MuiAppBar>
</div>
)
}; |
@archfz Could you create a codesandbox please? (You could start with one of the docs examples.) |
@archfz Sorry, missed this. What am I looking for here? I don't experience any layout changes. |
When you click on the character in the top right, it moves to the left when the menu item opens and then moves back to the right when the menu item closes. |
Could you open a new issue? It seems something new. |
@archfz Ok, it's a conflict with the tooltip. Let's ignore it. |
@oliviertassinari Well we should not ignore it cause it's a real issue. React-admin uses material UI and it actually is an issue out of the box. I have created an issue here #19203 |
The solution re-iterated by @Toshiuk is to simply add the following:
We really need to make solutions more easily findable! :-) |
This comment has been minimized.
This comment has been minimized.
just add the following css |
hello, in my app i use this solution. |
I experienced the same problems working with Dialogs. The following is the only solution that I have tried that both removes the shifting of content and still locks the scroll of the underlying page/removes its scrollbar. Solution:
|
You are just brilliant, Thank you |
How did you fixed content jump on menu open? |
It's a bad solution, because it disables scroll lock when dropdown menu is open. If you click on selector and scroll, the dropdown menu won't hide. |
Wanted to post the solution that worked best for us in case it helps someone else too.
|
Thank you so much for this! |
Thank you !, verified working on React Material UI v4 |
I believe that we have move the discussion on this issue to #17353. |
When a
Menu
opens, the page's scrollbar disappears. This may affect page layout. In my case, it jumps everything over to the right, which is a visual bug.Solution
Either A) fix this in the library, or B) Note this behavior in the docs, and provide ways of solving it:
https://material-ui.com/demos/menus/
The container for the things jumping is
absolute, left: 0, right: 0
, with sections that are eithertext-align: center
ordisplay: flex; flex-direction: column; align-items: center;
Your Environment
Related issues
These are all closed, and I didn't find the solution in them:
#8475 #7431 #6656 #8710
The text was updated successfully, but these errors were encountered: