angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.37k stars 6.75k forks source link

MdDialog not resizing height to contents on open #2351

Closed jt-helsinki closed 7 years ago

jt-helsinki commented 7 years ago

Bug, feature request, or proposal:

Bug

What is the expected behavior?

trying to create an MdDialog using the Material 2 library. Expect the dialog to automatically size to the contents of the dialog.

What is the current behavior?

It's all working perfectly except for the height which comes out at 100% of the browser window height.

What are the steps to reproduce?

If I set the height using a MdDialogConfig object then the height works properly. However this is not much good as if the form layout changes, the height will not adjust automatically thus running the risk of form elements being cut off.

export class MainHeader implements OnInit {
    constructor(private dialog: MdDialog,
                private viewContainerRef: ViewContainerRef) {

    }

    ngOnInit() {
        this.config = new MdDialogConfig();
        this.config.viewContainerRef = this.viewContainerRef;
    }

    openLoginModal() {
        this.dialogRef = this.dialog.open(LoginModal, this.config);

        this.dialogRef.afterClosed().subscribe((result: string) => {
            // do something 
            this.dialogRef = null;
        });
    }

}

If I don't pass in the config, same result.

What is the use-case or motivation for changing an existing behavior?

Using forms inside dialog.

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

Angular 4.0.0-beta.1 Material 2.0.0-alpha.11.3

Is there anything else we should know?

I thought this might be a stylesheet problem so I commented out the styles and the problem persisted.

To double check, I added a border to a <div> which surrounds the form. The form is the correct size as expected.