Skip to content

Dialogue - overflow scrolling on small screens and margins #2481

Open

Description

@ganySA

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:

image

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.

image

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?

Activity

  1. crisbeto commented on Dec 31, 2016

    @crisbeto
    Member

    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.

  2. self-assigned this
    on Dec 31, 2016
  3. ganySA commented on Dec 31, 2016

    @ganySA
    Author

    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.

  4. crisbeto commented on Dec 31, 2016

    @crisbeto
    Member

    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.

  5. added a commit that references this issue on Jan 25, 2017
    55f1974
  6. egdraper commented on Jan 27, 2017

    @egdraper

    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.

  7. jt-helsinki commented on Mar 29, 2017

    @jt-helsinki

    @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.

  8. crisbeto commented on Mar 29, 2017

    @crisbeto
    Member

    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.

  9. dmitrysteblyuk commented on Jul 20, 2017

    @dmitrysteblyuk

    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.

  10. dmitrysteblyuk commented on Jul 20, 2017

    @dmitrysteblyuk

    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

  11. dmitrysteblyuk commented on Jul 21, 2017

    @dmitrysteblyuk

    After a lot of juggling with css I stopped on the following styles (works alright in Chrome, FF, IE 11, Edge)

    html.cdk-global-scrollblock {
        width: initial;
        position: initial;
        overflow-y: initial;
    }
    
    body.modal-open {
        overflow: hidden;
    }
    
    body.modal-open .cdk-global-overlay-wrapper {
        pointer-events: all;
        display: block !important;
        overflow: auto;
        padding: 30px 0;
        position: fixed;
    }
    
    body.modal-open .cdk-overlay-pane {
        position: relative !important;
        margin: auto !important;
    }
    
    .cdk-overlay-backdrop {
        position: fixed !important;
    }
    
    .mat-dialog-container {
        margin: 0 auto 30px !important;
        height: auto !important;
        overflow: initial !important;
    }
    
    .mat-dialog-content {
        max-width: none !important;
        max-height: none !important;
        overflow: initial !important;
    }
    

    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).

  12. aleixsuau commented on Aug 31, 2017

    @aleixsuau

    Hi, looks like vh works (>=IE9):

    .mat-dialog-container {
      max-height: 70vh !important;
    }
    
  13. 23 remaining items

  14. added 2 commits that reference this issue on Jul 11, 2018
    0297e10
    d0ebb1e
  15. added 2 commits that reference this issue on Aug 23, 2018
    f31e8e5
    c5e50bc
  16. added a commit that references this issue on Oct 7, 2018
    58d7352
  17. added a commit that references this issue on Nov 24, 2018
    c7905ae
  18. added a commit that references this issue on Mar 1, 2019
    cc3ba6f
  19. added a commit that references this issue on Mar 30, 2019
    dccfb41
  20. uloga commented on Sep 27, 2019

    @uloga

    Add this to your dialog options: autoFocus: false,

    e.g:

    const dialogRef = this.dialog.open(ProductAlertDialog,{
          width: '100px',
          height: '200px',
          autoFocus: false,
          data: {name: "name", animal: "animal"}
        });
    

    and to css
    .mat-dialog-content{
    overflow: none;
    }

  21. evil-shrike commented on Jul 28, 2021

    @evil-shrike

    The simplest method to have v-scrollable dialogs I found so far:

    .mat-dialog-container {
      height: initial !important;
    }
    

    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.

  22. Exac commented on Jul 28, 2021

    @Exac

    @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).

  23. atifminhas commented on Jun 2, 2023

    @atifminhas

    Adding following css works somehow:

    .cdk-overlay-pane { overflow-y: auto; } .cdk-overlay-pane::-webkit-scrollbar{ display: none; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area: material/dialog

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions