question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Feature Request) MdDialog: Define a class for global overlay wrapper

See original GitHub issue

In MdDialog we can define in configs a class for overlay panel(panelClass) and backdrop(backdropClass), but we can not define a class for the wrapper.

The existent parameters are not enough to customize the dialog. Can we have a new parameter like wrapperClass for .cdk-global-overlay-wrapper?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
greg-mdcommented, Oct 31, 2017

@josephperrott For a login/registration like dialog, on small windows, I don’t want a scroll inside the panel, but I want a window scroll for that panel. I know this feature will not be implemented in material, because of Material spec(see https://github.com/angular/material2/issues/5302#issuecomment-312906868), but there are cases when you need it.

For such panels I can not just change the .cdk-* styles globally, because they are used for other components too, and they may become broken. So, I have to specify custom classes for panels that needs that feature.

Right now, as a workaround, I’m using the private property _overlayRef to set that class:

this.dialogRef = this.dialog.open(component, {
  panelClass: 'dialog-panel',
  backdropClass: 'dialog-backdrop',
});

// @TODO Hack. Needs to be refactored, because it uses a private property.
if (this.dialogRef['_overlayRef'].overlayElement) {
  this.dialogRef['_overlayRef'].overlayElement.parentElement.className += ' dialog-wrapper';
}

And styles to make panel scrollable in window:

.cdk-global-overlay-wrapper.dialog-wrapper {
  overflow: auto;
  pointer-events: auto;
}

.cdk-overlay-backdrop.dialog-backdrop {
  position: fixed;
}

.cdk-overlay-pane.dialog-panel {
  margin: auto;
}
1reaction
greg-mdcommented, Mar 20, 2018

@svenkeeter Looks like the backdrop was moved out from the dialog wrapper. You can manually move it back for these purposes:

const overlayEl = this.dialogRef['_overlayRef'].overlayElement;
overlayEl.parentElement.className += ' dialog-wrapper';
// Move backdrop back into the wrapper container
overlayEl.parentElement.insertBefore(overlayEl.parentElement.previousElementSibling, overlayEl);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way to modify the MatDialog overlay order?
Based on Eliseo's answer, no panel class modification needed. Reordering the cdk-global-overlay-wrapper elements is enough.
Read more >
How to build a reusable Modal Overlay/Dialog Using Angular ...
We will start by defining the configs of the overlay – OverlayConfig . In our case, we will just set the hasBackdrop and...
Read more >
angular-material/CHANGELOG.md - UNPKG
317, ### Features. 318. 319, * **autocomplete:** add md-input-class binding. ([#11102](https://github.com/angular/material/issues/11102)) ...
Read more >
Untitled
... Features * **autocomplete:** add md-input-class binding. ... custom components like `$mdDialog` or `$mdToast` only available in controller constructors.
Read more >
angular dialog prevent close on click outside - You.com
Prevent esc from closing the dialog but allow clicking on the backdrop to close ; export class DialogComponent { constructor(private dialogRef: MatDialogRef< ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found