Skip to content
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

Make an overlay always on top of other overlays #14650

Open
abdulkareemnalband opened this issue Dec 27, 2018 · 4 comments
Open

Make an overlay always on top of other overlays #14650

abdulkareemnalband opened this issue Dec 27, 2018 · 4 comments
Labels
area: cdk/overlay feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions

Comments

@abdulkareemnalband
Copy link

Please describe the feature you would like to request.

whenever a new overlay is created it is positions on top of other existing overlays (speaking wrt z-index).
provide a way to mark a overlay need to be shown always on top of other overlay's irrespective of order of creation

What is the use-case or motivation for this proposal?

In our application we are using overlay as container for in-app notifications (we don't use/follow material spec)
We also use overlay for different use-cases like full-window dialogs, custom drop-downs , and such things
opening new overlay is hiding the notifications which we do not want

@andrewseguin andrewseguin added feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions labels May 7, 2019
@csbenjamin
Copy link

csbenjamin commented Nov 28, 2020

For now, I am using the following workaround:

// somewhere_in_my_code.ts
const tmpClass = `panel-${Date.now()}`;
const dialog = this.dialog.open(ConfirmComponent,
  {data: {message}, panelClass: tmpClass, backdropClass: ['cdk-overlay-dark-backdrop', 'overlay-priority-1']});
dialog.afterOpened().subscribe(() => {
  if (typeof document !== 'undefined') {
    const panel = document.querySelector(`.${tmpClass}`);
    if (panel && panel.parentElement) {
      panel.parentElement.classList.add('overlay-priority-1');
    }
  }
});
// styles.scss
.overlay-priority-1 {
    z-index: 1001 !important;
}

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 1, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 22, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@Fedduh
Copy link

Fedduh commented May 31, 2024

Just my 2 cents for others looking for an answer.

To achieve what you want, set the .cdk-global-overlay-wrapper element to have a z-index that's higher than the default of 1000. You cannot apply a style directly to this, but you can apply a class to the child element (panelClass).

With modern css you can also use the :has selector to style an element based on child elements. This way you don't have to use the javscript alternative in the previous comment. (caniuse support for :has is at 91% and supported in all major browsers)

const overlayConfig = new OverlayConfig({
      // .. other settings
      panelClass: 'overlay-priority',
    });

And in your global (s)css

.cdk-global-overlay-wrapper:has(.cdk-overlay-pane.overlay-priority) {
  z-index: 1001; // default modals are 1000
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/overlay feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

5 participants