-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Dialogue - overflow scrolling on small screens and margins #2481
Comments
First of all, you're not using the That being said, I'll take a look at why the element still goes outside of the viewport. |
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. |
Currently, the dialog's scrollable content (md-dialog-content) is limited to 65% of the viewport height, however on smaller screens the dialog still ends up being too high (see issue angular#2481). This proposal reworks the `md-dialog-content` to make it take up all of the remaining height, instead of being hardcoded to 65%. The max height is provided by the wrapper instead. The issue with this approach is that the direct parent of the `md-dialog-content` has to be `display: flex`, which can end up modifying the user's content. I see a couple of solutions, but I'm not sure which one to go with: 1. Conditionally add the flexbox styles, if the user has used `md-dialog-content`. That's what this PR is doing, however using `querySelector` to find out if the dialog content is there feels a little dirty. We're not able to use `@ViewChild` or `@ContentChild` to query for it. 2. Force the user to use our dialog content elements. This is what Material 1 was doing.
Currently, the dialog's scrollable content (md-dialog-content) is limited to 65% of the viewport height, however on smaller screens the dialog still ends up being too high. This proposal reworks the `md-dialog-content` to make it take up all of the remaining height, instead of being hardcoded to 65%. The max height is provided by the wrapper instead. Fixes angular#2481.
Currently, the dialog's scrollable content (md-dialog-content) is limited to 65% of the viewport height, however on smaller screens the dialog still ends up being too high. This proposal reworks the `md-dialog-content` to make it take up all of the remaining height, instead of being hardcoded to 65%. The max height is provided by the wrapper instead. Fixes angular#2481. Fixes angular#2775.
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. |
@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. |
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):
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 |
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). |
Hi, looks like vh works (>=IE9):
|
any fix for this? |
+1 The dialog in AngularJs Material is really good, responsive and customisable. The implementation of the dialog in Angular Material is actually a deal breaker. Take a look at the old one, thats how it should work. I want to use Angular Material but i cant work with this.. |
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes #2481. Fixes #3239. Fixes #6584. Fixes #8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
+1 @crisbeto any update on this? thanks! |
@aleixsuau best solution so far! Thank you! |
@makkart i am sorry but is that so hard for you ? if it is go to see how ReactJS is doing it. constructor(public dialog: MatDialog) {}
openDialog(): void {
let dialogRef = this.dialog.open(DialogOverviewExampleDialog, {
width: '250px',
data: { name: this.name, animal: this.animal }
});
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.animal = result;
});
} |
I prefer do:
|
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
I like to build it like the bootstrap modals: add these styles:
|
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
Note that hacks targeting |
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes #2481. Fixes #3239. Fixes #6584. Fixes #8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes #2481. Fixes #3239. Fixes #6584. Fixes #8493.
According the docs, dialogs must to follow this basic structure to have a scrollable content:
|
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes #2481. Fixes #3239. Fixes #6584. Fixes #8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes #2481. Fixes #3239. Fixes #6584. Fixes #8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars. * Uses flexbox to ensure that the dialog content elements are always at the appropriate size. Fixes angular#2481. Fixes angular#3239. Fixes angular#6584. Fixes angular#8493.
Add this to your dialog options: autoFocus: false, e.g:
and to css |
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. |
@evil-shrike It doesn't seem to allow the dialog to be scrollable, unless you prefix |
Adding following css works somehow:
|
Bug, feature request, or proposal:
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
What are the steps to reproduce?
Providing a Plunker (or similar) is the best way to get the team to see your issue.
https://plnkr.co/edit/DrI42Su0v6OntJkjUNOI?p=preview
What is the use-case or motivation for changing an existing behavior?
The current modal is only useful for very simple use cases.
Which versions of Angular, Material, OS, browsers are affected?
Latest.
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: