Skip to content

MatDialog mat-dialog-actions is not at the bottom of the dialog #4609

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

Open
ashishdoneriya opened this issue May 16, 2017 · 52 comments
Open

MatDialog mat-dialog-actions is not at the bottom of the dialog #4609

ashishdoneriya opened this issue May 16, 2017 · 52 comments
Labels
area: material/dialog P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@ashishdoneriya
Copy link

ashishdoneriya commented May 16, 2017

Bug:

Angular Material is not placing md-dialog-actions at the bottom

What is the expected behavior?

Should be at the bottom

What is the current behavior?

Currently, it is placed just after md-dialog-content

What are the steps to reproduce?

Add md-dialog-actions
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://plnkr.co/edit/S2D0g6NOPpVRYoc6KA7L?p=preview

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

angular 4, material ^2.0.0-beta.5, os ubuntu 16.04, typescript ~2.0.3, browser : chrome

@ashishdoneriya ashishdoneriya changed the title MdDialog action buttons are not at the bottom MdDialog md-dialog-actions is not at the bottom May 16, 2017
@jelbourn jelbourn added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label May 18, 2017
@jelbourn
Copy link
Member

@crisbeto looks like this happens when explicitly setting a height on the dialog

@beazergood
Copy link

Oh this is for ng2, same is happening for me using material 1.1.3

@rthewhite
Copy link

I can confirm it indeed seems to occur the moment you set a specific height on the dialog.
The moment you specify an height (in my case 65%) the title and actions don't stay fixed in place and there are 2 scrollbars. See:

https://plnkr.co/edit/1Vn3D3E2ozdO80rLlleS?p=preview

@rthewhite
Copy link

Also duplicate of #4053

@ChenReuven
Copy link

Is there any news about this issue?

thanks

@pauloapi
Copy link

pauloapi commented Apr 4, 2018

Any news?

@Chris2011
Copy link

The other ticket points to this ticket :D but I can't see any solution(?)

@atrombet
Copy link

I have found this to work as a temporary fix when explicitly setting height on a MatDialog.

my-dialog.component.html:

<div class="fixActionRow">
    <h1 mat-dialog-title></h1>
    <div mat-dialog-content></div>

    <div class="spacer"></div>

    <div mat-dialog-actions></div>
</div>

my-dialog.component.css:

.fixActionRow {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.spacer {
  flex-grow: 1;
}

@stephengardner
Copy link

stephengardner commented Jun 16, 2018

Is this a feature instead of a bug? Are we intended to replicate this ourselves? This issue has been open a longgg time

@fergalddaly
Copy link

not specifying the height worked for me.

@vinagreti
Copy link
Contributor

vinagreti commented Sep 26, 2018

Is there any update about this issue? @jelbourn

@ashishdoneriya

This comment has been minimized.

@Chris2011
Copy link

Please reopen the bug ticket, it was not implemented and to say moving to vue will not resolve the ticket. @ashishdoneriya if you are not interested anymore in it, fine, but leave it open for everyone else. Thx.

@ashishdoneriya
Copy link
Author

@Chris2011 ok chris

@vinagreti
Copy link
Contributor

My experience:

Bug, feature request, or proposal:
Bug

What is the expected behavior?
Actions to be at the bottom of the dialog

What is the current behavior?
Actions right after content

What are the steps to reproduce?
StackBlitz starter: https://stackblitz.com/edit/angular-cuikyx

Which versions of Angular, Material, OS, TypeScript, browsers are affected?
[email protected], [email protected], any browser and any OS

@vinagreti
Copy link
Contributor

@crisbeto I saw that you are working on dialog fixes. Could you please tell us if this issue will be fixed? It was opened more than a year ago and nothing has been done.
Thanks a lot!!!

@simeyla
Copy link

simeyla commented Oct 20, 2018

There really really needs to be a better way to specify different dialog scaling strategies beyond the existing positioning strategies (such as full screen with an optional margin). Then problems like this would go away.

I expect the primary reason to set height on a dialog in the first pace is to make it stretch, or stop it overflowing the page. The number one thing a dialog control should do it take the burden of sizing away from me!

@0xDones
Copy link

0xDones commented Nov 30, 2018

Any news or workaround for this? @atrombet's solution didn't work for me. =(

@manklu
Copy link

manklu commented Nov 30, 2018

@dpolicastro
https://stackblitz.com/edit/angular-cuikyx-pnx9we

@lekha-badarinath
Copy link

Yes, please fix this. Workarounds are fine, but it is a lot more time saving if it comes placed correctly out of the box. :(

@rockResolve
Copy link

rockResolve commented May 22, 2020

As @dpolicastro mentioned none of these solutions work if only minHeight and not height) is set.

@breket
Copy link

breket commented Jun 15, 2020

Hey guys! Time to fix it! Every workaround makes my code just ugly...

@rockResolve
Copy link

I refined the above work of @DanielHabenicht to handle minHeight.

helper my-dialog.component.css:

// HACK Work around for Angular Material bug
// Setting height or min-height placed .mat-dialog-actions immediately below mat-dialog-content
// It should be at the bottom.
// Issue & fix https://github.com/angular/components/issues/4609
// Below css requires code to fix min-height.
// Search 'DIALOG MIN HEIGHT' for paired code fix
mat-dialog-container {
  display: block;
  height: 100%;

  .my-dialog {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: inherit;
  }

  .mat-dialog-title {
    display: block;
  }

  .mat-dialog-content {
    flex-grow: 1;
    max-height: unset;
  }
}

paired with helper dialog.service.ts:

  showDialog<T, D = any, R = any>(
    componentOrTemplateRef: ComponentType<T> | TemplateRef<T>,
    config?: MatDialogConfig<D>
  ) {
    return this.dialog.open(
      componentOrTemplateRef,
      createConfig(config)
    );
  }

  private createConfig(config: MatDialogConfig<any> | undefined) {
    return {
      // First Default settings
      width: '570px',

      // minHeight: '300px',
      // Remove mat-dialog-container padding 48px so it can be inherited by
      // mat-dialog-container first child. Inherit makes mat-dialog-container
      // first child too high by padding.
      // So calculate as 300px - 48px of mat-dialog-container padding
      // Search 'DIALOG MIN HEIGHT' for paired css fix
      minHeight: '252px',

      disableClose: true,

      // Then User settings
      ...config
    };
  }

To make the height & minHeight property values pass down to the dialog body's container, each parent (i.e. my-dialog) between it and ancestor mat-dialog must pass them through e.g. ...

dialog instance component my-confirm-dialog.component.scss

my-confirm-dialog {
  height: 100%;
  min-height: inherit;
}

and set viewEncapsulation none with my-confirm-dialog.component.ts

@Component({
  selector: 'my-confirm-dialog',
  templateUrl: './my-confirm-dialog.component.html',
  styleUrls: ['./my-confirm-dialog.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class MyConfirmDialogComponent implements OnInit {

@Mgiannig
Copy link

Mgiannig commented Jul 3, 2020

Any news?
Definitely moving to react or vue, tired of this WorkAroungular life

@vinagreti
Copy link
Contributor

@austinkulp It isn't a framework. It is only a lib and has nothing to compare with Vue.
But, it is really a shame they still didn't fix it.

@alekplay
Copy link

alekplay commented Sep 18, 2020

@DanielHabenicht this is great, but it seems to remove my backdrop... 🤔 Upon removing the override the backdrop returns. Any idea how these are correlated?

EDIT:
Seems as though overriding the panelClass also overrides all the other default values, including hasBackdrop. This fixes it:

{ provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: { panelClass: 'mat-dialog-override', hasBackdrop: true }}

@angular angular deleted a comment from thegr8snarfle Oct 28, 2020
@jelbourn jelbourn changed the title MdDialog md-dialog-actions is not at the bottom MatDialog mat-dialog-actions is not at the bottom of the dialog Feb 23, 2021
@jurgh1
Copy link

jurgh1 commented Mar 29, 2021

For me,

.mat-dialog-content {
  height: 100%;
}

did the trick, when I have a set dialog height

const dialogConfig = new MatDialogConfig();
dialogConfig.height = '80%';

@skwiotek
Copy link

Hello,
is there any work on it from Angular developers? It is shown here that it is a known bug and a requested important feature.
Please help. Maybe with a good workaround... !?
Thanks!

@zdenek-horak
Copy link

The proposed fix didn't worked for me. Following code solved my case (when specifying height: '85vh' in this.dialog.open):

.mat-dialog-content {
  max-height: initial!important;
  height: calc(100% - 52px);
}

.mat-dialog-container {
  max-height: 90vh;
}

@SadiinsoSnowfall
Copy link

The bug is still present in Angular Material 13 😕

@ChelseaChilders
Copy link

Leaving a comment to note that this is still a popular issue that devs want fixed please. Work-arounds are ugly.

@SelectiveHouse
Copy link

SelectiveHouse commented Jan 31, 2022

Also jumping on here to be annoying and say this bug is still present

@lacamilla
Copy link

Using Angular 13. If I don't set the height of the dialog component then the dialog's action buttons are nicely positioned at the bottom of the dialog. However, when internal dialog's content changes size (say, tabs and each tab is different height) then the whole dialog window is resizing depending on the content. This is quite frustrating UX, so I'd have fixed the height of the dialog. With this, I get another issue, this time UI related, the action buttons sometimes end up in the middle of the dialog. The whole situation cannot be helped with the fact that styling dialogs without turning off viewEncapsulation isn't possible.

@JanBA1990
Copy link

Also jumping on here to be annoying and say this bug is still present

Joining the queue. The proposed solutions in the comments are not satisfying at all.

@AlonsoK28
Copy link

AlonsoK28 commented Jul 18, 2022

Some fix for this ?

image

My project dependencies:

"@angular/material": "^14.0.3"

@bardus-hobus
Copy link

It is now 5 years, and this is still an issue.

@shprink
Copy link

shprink commented Oct 7, 2022

If you don't want to wait another 5 years to fix your issue here is what works for me with a fullscreen dialog:

open dialog config:

this.dialog.open(YourDialog, {
      maxWidth: '90vw',
      maxHeight: '90vh',
      width: '90vw',
      height: '90vh',
    });

modal style

      [mat-dialog-content] {
      // 32px is mat-dialog-title height
      // 68px is mat-dialog-actions height
        max-height: calc(100% - 32px - 68px); 
      }

@gitprzemek
Copy link

There is simpler css workaround for that, without adding additional html elements.

In your component html:

<section class="dialog-container">
  <div mat-dialog-title></div>
  <div mat-dialog-content></div>
  <div mat-dialog-actions></div>
</section>

In your scss file for that component:

::ng-deep .mat-dialog-container {
  display: flex;
}
.dialog-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.dialog-container .mat-dialog-content {
  flex-grow: 1;
}

@jsmalme
Copy link

jsmalme commented Oct 31, 2023

Who knew getting the modal action buttons to line up on the bottom of the page would be such a challenge? I guess I'll just use a bootstrap modal or something.

@NikolayNN
Copy link

It works for me

<h2 mat-dialog-title>Title</h2>
<mat-dialog-content></mat-dialog-content>
<mat-dialog-actions></mat-dialog-actions>
:host {
  height: 100%;
  display: flex;
  flex-direction: column;
}

mat-dialog-content {
  flex-grow: 1;
}

mat-dialog-actions {
  margin-top: auto;
}

stackblitz

@Spartbrine
Copy link

It still happening at Angular 18?
Im with that error at Angular 15

@victor314159
Copy link

Still hitting that bug with Angular 18...

@DanangPurnanto
Copy link

It's still happened at Angular 19..

@NelDev1104
Copy link

NelDev1104 commented May 13, 2025

I found this to work for me. Having no mat-dialog-content and setting a height to that will make the actions stick to the bottom.

<div class="content">{...}</div>
<div mat-dialog-actions></div>
.content{
height: 80vh
}

Use this if you dont need mat-dialog-content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/dialog P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.