1
votes

I am implementing Angular Material Dialog in my project. It is working, however, when I open the dialog, my other screen(parent component calling the dialog) disappears in the background. See the image, the background does not shows the content of the page. enter image description here

I want to implement it like its shown in the angular material website, where background is visible. (See Image) enter image description here

I don't understand the issue, as I have implemented it as described in the website.

1
Any error in console ? Can you show your code ? If you did like Material, then it shoud work like this - Emilien
Can you provide body css? - Bozhinovski
@Emilien No there is no Error in Console. Yes, I did used it as suggested in the example on website as well as stackblitz - sahil kharya
@VladimirBozhinovski I haven't provided any CSS for dialog - sahil kharya
The answer provided solves my issue. Thanks:) - sahil kharya

1 Answers

1
votes

Try adding noopscrollstrategy to the dialog reference:

const dialogRef = this.dialog.open(DialogComponent, {
        width: '250px',
        data: { some data },
        scrollStrategy: new NoopScrollStrategy() // add this line
    });

and dont forget to import it

import { NoopScrollStrategy } from '@angular/cdk/overlay';

If that doesn't work try adding css:

.cdk-global-scrollblock{
    position: static !important;
    width: initial !important;
    overflow-y: inherit !important;
  }

If you want to understand what NoopScrollStrategy is doing behind the scene read the documentation: https://material.angular.io/cdk/overlay/api

Happy coding