material-components / material-components/material-web

Problem with scrims when multiple dialogs are opened

Open
#5,500 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
11.3k
Forks
1.1k
Avg merge
20h 28m
Merged PRs (30d)
13

Description

### 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](https://github.com/material-components/material-web/assets/2827383/32e82ec2-f79e-4359-b3d9-551a65d4676e)

### Reproduction

https://lit.dev/playground/#gist=d125eb4ef8a6086b907630c9eb28b6e2

### Workaround

Workaround proposed by @sorvell :

```js
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Lit playground reproduction and the MdDialog entry point imported from @material/web/dialog/dialog.js. Reproduce multiple open dialogs in Chrome or Firefox, then inspect scrim placement and the open/close animation behavior. Done means stacked dialogs have clear boundaries without requiring the proposed workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.