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

Problem with scrims when multiple dialogs are opened #5500

Open
vdegenne opened this issue Feb 28, 2024 · 1 comment
Open

Problem with scrims when multiple dialogs are opened #5500

vdegenne opened this issue Feb 28, 2024 · 1 comment

Comments

@vdegenne
Copy link
Contributor

What is affected?

Component

Description

When opening multiple dialogs, scrim are not layered properly resulting in dialogs opening in top of each other with no clear way to discern boundaries.

image

Reproduction

https://lit.dev/playground/#gist=69e00d591947f65c8b9b19860867d08b

Workaround

Workaround proposed by @sorvell :

import {MdDialog} from '@material/web/dialog/dialog.js';

MdDialog.addInitializer(async (instance: MdDialog) => {
  await instance.updateComplete;
  instance.dialog.prepend(instance.scrim);
  instance.scrim.style.inset = 0;
  instance.scrim.style.zIndex = -1;

  const {getOpenAnimation, getCloseAnimation} = instance;
  instance.getOpenAnimation = () => {
    const animations = getOpenAnimation.call(this);
    animations.container = [...animations.container, ...animations.dialog];
    animations.dialog = [];
    return animations;
  };
  instance.getCloseAnimation = () => {
    const animations = getCloseAnimation.call(this);
    animations.container = [...animations.container, ...animations.dialog];
    animations.dialog = [];
    return animations;
  };
});

Is this a regression?

Yes. This used to work, but now it doesn't.

Affected versions

1.3.0

Browser/OS/Node environment

Chrome/Firefox

@vdegenne
Copy link
Contributor Author

As a side note, this issue is even more significant because dialogs can usually be lazy loaded; Using the workaround above means that the code for <md-dialog> will be loaded in the main bundle (unless the code for this fix is imported everywhere where dialogs are used which makes managing development in a multi-dialog app really cumbersome).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant