Skip to content

[dialog][alert dialog] Add renderMode prop to Backdrop part #2037

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Jun 2, 2025

Closes #1477

Comment on lines +77 to +86
/**
* How to render the backdrop when dialogs are nested in the React tree.
* @default 'root'
* @description
* - `root`: Render only one backdrop at the root dialog.
* - `leaf`: Render only one backdrop at the leaf dialog.
* - `always`: Always render the backdrop regardless of nesting.
*/
renderMode?: 'root' | 'leaf' | 'always';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation

Copy link

pkg-pr-new bot commented Jun 2, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@2037

commit: 7d3a64d

Copy link

netlify bot commented Jun 2, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 7d3a64d
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/683e5c33944ba80008472bfd
😎 Deploy Preview https://deploy-preview-2037--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mui-bot
Copy link

mui-bot commented Jun 2, 2025

Bundle size report

Total Size Change:${\tiny{\color{red}▲}}$+356B(+0.02%) - Total Gzip Change:${\tiny{\color{red}▲}}$+172B(+0.04%)
Files: 41 total (0 added, 0 removed, 3 changed)

Show 3 more bundle changes

@base-ui-components/reactparsed:${\tiny{\color{red}▲}}$+178B(+0.06%) gzip:${\tiny{\color{red}▲}}$+90B(+0.10%)
@base-ui-components/react/alert-dialogparsed:${\tiny{\color{red}▲}}$+89B(+0.17%) gzip:${\tiny{\color{red}▲}}$+41B(+0.24%)
@base-ui-components/react/dialogparsed:${\tiny{\color{red}▲}}$+89B(+0.17%) gzip:${\tiny{\color{red}▲}}$+41B(+0.24%)

Details of bundle changes

Generated by 🚫 dangerJS against 7d3a64d

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 2, 2025
@flaviendelangle
Copy link
Member

Not a huge fan of the prop name.
I saw quite a lot of renderXXX props that were render props (renderItem={item => <Item item={item} />}).
So I wouldn't use the same type of name for a prop like the one created in this PR.

@atomiks
Copy link
Contributor Author

atomiks commented Jun 2, 2025

@flaviendelangle yeah I don't like it either but it describes whether it doesn't render or not, so what would it be called?

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 2, 2025
@flaviendelangle
Copy link
Member

I don't have a very good proposal :/
nestedDialogRenderMode is very verbose

@atomiks
Copy link
Contributor Author

atomiks commented Jun 4, 2025

nestedRenderMode seems ok though 🤔 @colmtuite

@colmtuite
Copy link
Contributor

Why would you want leaf instead of root or always?

@atomiks
Copy link
Contributor Author

atomiks commented Jun 4, 2025

You want leaf when you don't want stacking effects and always want the topmost dialog to dim everything behind it - the linked issue shows a screenshot:

#1477

The stacked dialogs in the docs do dim a parent nested dialog already, but use an ::after overlay instead:

Screenshot 2025-06-04 at 3 55 49 pm

It turns out that due to re-parenting, leaf doesn't play nicely with transitions. Even if it animated here, the cross-fade may not be perfect with the regular ease timing function? So maybe the ::after pseudo-element is actually the best technique to dim parent dialogs already 🤔

Screen.Recording.2025-06-04.at.4.08.01.pm.mov

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

Successfully merging this pull request may close these issues.

[dialog] Provide an escape hatch for displaying backdrops on nested dialogs
4 participants