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

[dialog] Removing a closed nested dialog from the tree increments parent's nested open dialog count #1279

Closed
Studio384 opened this issue Jan 2, 2025 · 1 comment · Fixed by #1280
Assignees
Labels
bug 🐛 Something doesn't work component: dialog This is the name of the generic UI component, not the React module!

Comments

@Studio384
Copy link

Studio384 commented Jan 2, 2025

Bug report

Current behavior

When you are in a dialog and for whatever reason a nested dialog that isn't open yet is removed from the tree, the parent dialog will set --nested-dialogs to 1 despite no nested dialog being open.

Expected behavior

Removing a nested dialog doesn't affect its parent.

Reproducible example

https://codesandbox.io/p/sandbox/friendly-maria-ctqgff?file=%2Fsrc%2FApp.tsx%3A20%2C32

Base UI version

v1.0.0 alpha 4

Which browser are you using?

Edge 131

Which OS are you using?

Windows 11 24H2

Which assistive tech are you using (if applicable)?

N/A

Additional context

N/A

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 2, 2025
@zannager zannager added the component: dialog This is the name of the generic UI component, not the React module! label Jan 2, 2025
@mj12albert mj12albert added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 3, 2025
@mj12albert mj12albert assigned mj12albert and unassigned siriwatknp Jan 3, 2025
@mj12albert
Copy link
Member

mj12albert commented Jan 3, 2025

I think the issue is here: https://github.com/mui/base-ui/blob/master/packages/react/src/dialog/root/useDialogRoot.ts#L106-L108

When a closed nested dialog unmounts, it calls onNestedDialogOpen from the parent's context, which incremented the nested dialog count in the parent.

I think this isn't needed – if it's closed when unmounting, it shouldn't have been included in the nested dialog count to begin with 🤔

@mj12albert mj12albert changed the title [dialog] Removing a nested dialog from the tree results in the nested dialog variable to change [dialog] Removing a closed nested dialog from the tree increments parent's nested open dialog count Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: dialog This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants