You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dialogue - overflow scrolling on small screens and margins #2481
The current dialogue does not seem to support sizing and scrolling on smaller screen sizes / small devices. This was possible on the material 1 dialogue. If the vertical height of the screen was incredibly small scrollbars would appear see this screenshot:
With version 2 - the dialogue is pushed off the screen and no scrollbars ever appear in the middle. It does not maintain any margins on the top or bottom.
Maybe there is this a means this can be achieved but the examples are quite primitive.
What is the expected behavior?
When screen is decreased in size scrollbars should appear for the content.
What is the current behavior?
The current dialogue is pushed off the screen with no margin at the top or bottom. The content remains the same size
First of all, you're not using the md-dialog-content properly since you're overriding it's height. You're only supposed to wrap your content with it. E.g. <div md-dialog-content style="height: 500px"> should turn into <div md-dialog-content><div style="height: 500px"> in your example.
That being said, I'll take a look at why the element still goes outside of the viewport.
Reacted by Domas, ifour-dinesh, Sergi, nifiro and Utkarsh Mehta
Sorry that was purely for illustration purposes. Thanks for looking into it. I think the main issue here is that because the dialogue is not limited to the screen bounds it never forces "overflow" to work properly on the content area.
If you set up the HTML like I mentioned it will get the overflow, however when you go to a really small screen (< 200px in height), then it starts going out of the viewport. I'm working on a fix for it.
May I recommend a design suggestion since it is being worked on? It seems like modals are starting to follow a design similar to bootstrap-4's modal or Avenxo's modal. Where the scrolling happens outside the window, rather than within.
Perhaps this window should remain centered until it is near the height of the browser window, then switch to a fixed position 25px from the top, and expands downward.
Reacted by Robin Regmi, JP Santos, Andrew, waynestorrie, Joshua Wright, MohamadReza Mash'al and Yipin Xiong
It is still open. I was working on it a few days ago, but it's a bit tricky to get it working everywhere (IE 11 in particular) with the way we have the overlays set up (we need multiple nested flexboxes which ends up breaking in one way or another). I'm still looking for a proper way to do it.
Is there any update on this? Maybe there's a workaround for the case when dialog is pushed off the screen? I'm trying to make it scrollable but it's not that simple with current layout.
I managed to make dialog scrollable using these styles (from ng-bootstrap):
html {
position: initial !important;
overflow-y: initial !important;
}
html.cdk-global-scrollblock body {
overflow: hidden;
}
.cdk-overlay-container {
overflow: auto;
}
Although, cdk-global-scrollblock class is added to html only if dialog is opened when there's already a scrollbar shown on the page. If scrollbar is shown after dialog is opened (e.g. dialog is being opened instantly, scrollbars are shown after some ajax requests completed) then cdk-global-scrollblock class won't be added to html
Plus .modal-open should be added to body when at least one modal is opened and backdrop div should be moved outside of overlay wrapper and placed before it (like it's done in ng-bootstrap).
Reacted by Mykhailo Kovetskyi, Alex Szabó, Guillaume Nury, nicolasBiosco, Corey Megown, rithvik-reddy-koripelli, Kristiqn Tachev, Simon Bland, Trym Todalshaug, Suhel Khan and 8 more
There's an alternative but it also creates h-scrolling in all select dropdowns
.cdk-overlay-pane {
overflow-y: auto;
}
The idea of specifying heigh in px for dialog is quite strange. Maybe it works for very basic dialogs like MsgBox but not for complex UI. So even using default 400px looks strange. Ideally dialog should adapt to content by default and if it isn't fitting that create v-scrolling automatically w/o all that hacks with styles.
Reacted by DEEP MEHTA, Jin Liang and Markus Schaber
@evil-shrike It doesn't seem to allow the dialog to be scrollable, unless you prefix ::ng-deep to the css selector (in which case the actions height is increased).
Activity
crisbeto commentedon Dec 31, 2016
First of all, you're not using the
md-dialog-contentproperly since you're overriding it's height. You're only supposed to wrap your content with it. E.g.<div md-dialog-content style="height: 500px">should turn into<div md-dialog-content><div style="height: 500px">in your example.That being said, I'll take a look at why the element still goes outside of the viewport.
ganySA commentedon Dec 31, 2016
Sorry that was purely for illustration purposes. Thanks for looking into it. I think the main issue here is that because the dialogue is not limited to the screen bounds it never forces "overflow" to work properly on the content area.
crisbeto commentedon Dec 31, 2016
If you set up the HTML like I mentioned it will get the overflow, however when you go to a really small screen (< 200px in height), then it starts going out of the viewport. I'm working on a fix for it.
proposal(dialog): better handling of scrollable content
refactor(dialog): better handling of scrollable content
refactor(dialog): better handling of scrollable content
egdraper commentedon Jan 27, 2017
We have been suffering from the same problem.
May I recommend a design suggestion since it is being worked on? It seems like modals are starting to follow a design similar to bootstrap-4's modal or Avenxo's modal. Where the scrolling happens outside the window, rather than within.
Perhaps this window should remain centered until it is near the height of the browser window, then switch to a fixed position 25px from the top, and expands downward.
jt-helsinki commentedon Mar 29, 2017
@crisbeto is this issue still open. I'm also experiencing this problem with 2.0.0-beta.2. I note that this thread was discussed prior to this release.
Please advise.
crisbeto commentedon Mar 29, 2017
It is still open. I was working on it a few days ago, but it's a bit tricky to get it working everywhere (IE 11 in particular) with the way we have the overlays set up (we need multiple nested flexboxes which ends up breaking in one way or another). I'm still looking for a proper way to do it.
dmitrysteblyuk commentedon Jul 20, 2017
Is there any update on this? Maybe there's a workaround for the case when dialog is pushed off the screen? I'm trying to make it scrollable but it's not that simple with current layout.
dmitrysteblyuk commentedon Jul 20, 2017
I managed to make dialog scrollable using these styles (from ng-bootstrap):
Although, cdk-global-scrollblock class is added to html only if dialog is opened when there's already a scrollbar shown on the page. If scrollbar is shown after dialog is opened (e.g. dialog is being opened instantly, scrollbars are shown after some ajax requests completed) then cdk-global-scrollblock class won't be added to html
dmitrysteblyuk commentedon Jul 21, 2017
After a lot of juggling with css I stopped on the following styles (works alright in Chrome, FF, IE 11, Edge)
Plus .modal-open should be added to body when at least one modal is opened and backdrop div should be moved outside of overlay wrapper and placed before it (like it's done in ng-bootstrap).
aleixsuau commentedon Aug 31, 2017
Hi, looks like vh works (>=IE9):
23 remaining items
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
fix(dialog): improved handling of scrollable content
uloga commentedon Sep 27, 2019
Add this to your dialog options: autoFocus: false,
e.g:
and to css
.mat-dialog-content{
overflow: none;
}
evil-shrike commentedon Jul 28, 2021
The simplest method to have v-scrollable dialogs I found so far:
There's an alternative but it also creates h-scrolling in all select dropdowns
The idea of specifying heigh in px for dialog is quite strange. Maybe it works for very basic dialogs like MsgBox but not for complex UI. So even using default 400px looks strange. Ideally dialog should adapt to content by default and if it isn't fitting that create v-scrolling automatically w/o all that hacks with styles.
Exac commentedon Jul 28, 2021
@evil-shrike It doesn't seem to allow the dialog to be scrollable, unless you prefix
::ng-deepto the css selector (in which case the actions height is increased).atifminhas commentedon Jun 2, 2023
Adding following css works somehow:
.cdk-overlay-pane { overflow-y: auto; } .cdk-overlay-pane::-webkit-scrollbar{ display: none; }