mui / mui/base-ui

[dialog] portal stays "mounted" when popup is removed

Open
#2,186 5 comments 2 reactions 0 assignees View on GitHub
component: dialog has workaround type: bug
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

Description

# Bug report

Its a bit hard to explain, but I've created an example here: https://codesandbox.io/p/devbox/pedantic-grass-22zl8v?workspaceId=ws_9E7g8meGhxx9KyReSrgWiy

Steps to reproduce:
- Create a dialog where the `Dialog.Popup` is dynamically rendered depending on the `open` state
- When the dialog is dismissed and the `Dialog.Popup` is switched out with anything else (in the examle its `null`)
- After the `Dialog.Popup` disappears the `Dialog.Portal` stays around indefinitely

## Current behavior

The `Dialog.Portal` stays around even when the `Dialog.Popup` is gone and thus no transition / animation can occur to unmount the `Dialog.Popup`.

## Expected behavior

The `Dialog.Portal` should not wait for any animations to complete when there is no `Dialog.Popup` to perform any animations.

## Reproducible example

https://codesandbox.io/p/devbox/pedantic-grass-22zl8v?workspaceId=ws_9E7g8meGhxx9KyReSrgWiy

## Base UI version

1.0.0-beta.0

## Which browser are you using?

Firefox 139.0.4 (64-Bit)

## Which OS are you using?

Windows 11

## Additional context

Provide any additional context that might help us identify the problem and find a solution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.