adobe / spectrum-web-components

Spectrum Web Components
https://opensource.adobe.com/spectrum-web-components/
Apache License 2.0
1.21k stars 192 forks source link

fix(overlay): prevent modal overlays from closing and fix memory leak #4561

Open lehelen19 opened 2 weeks ago

lehelen19 commented 2 weeks ago

Description

Prevents a modal overlay that's not on top of the stack from closing when a user clicks outside of the overlay's ancestor path. For example, when there are two modal overlays stacked on top of each other, clicking on the top overlay will not close the one below it.

Additionally, clean up the reference to this.lastOverlay to prevent a memory leak.

Related issue(s)

Motivation and context

Before the Overlay v2 API changes, overlays would behave as described above. It is unexpected for the overlay on the bottom to close on a random click, especially when the top overlay doesn't close.

How has this been tested?

We are actively testing this behavior in Express.

Screenshots (if appropriate)

Types of changes

Checklist

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.