feat(react-dialog): add appearance to backdrop slot#35692
feat(react-dialog): add appearance to backdrop slot#35692mainframev wants to merge 11 commits intomicrosoft:masterfrom
Conversation
📊 Bundle size report
Unchanged fixtures
|
|
Pull request demo site: URL |
|
TBH, I'm not sure I understand the purpose of the @mainframev, have you considered adding a prop to prevent the backdrop from being transparent, even when the dialog is nested? This might be clearer than using |
79c1a81 to
946c759
Compare
946c759 to
be42731
Compare
be42731 to
8dd2d1a
Compare
Yeah, I agree that it was not very well thought through very well. I thought in the direction of adding a This would be a convenient prop that makes users lives easier, especially since we have already received several questions about this. Alternatively, we could approach this differently by exposing a data attribute on the backdrop slot, for example: backdrop={{ 'data-backdrop-appearance': 'dimmed' }}. This could help avoid potential confusion caused by having both backdrop and backdropAppearance props at the same time. |
2985d80 to
2d44af2
Compare
f5ce3f2 to
45c0108
Compare
da952d2 to
4f2ca66
Compare
dmytrokirpa
left a comment
There was a problem hiding this comment.
LGMT, just two things to address and should be good to go:
- Clarify why do we need to remove the
appearanceprop from thebackdropslot - Could we add some tests (VR, e2e, etc) to test the old/new behavior?
...omponents/react-dialog/library/src/components/DialogSurface/useDialogSurfaceStyles.styles.ts
Outdated
Show resolved
Hide resolved
...omponents/react-dialog/library/src/components/DialogSurface/useDialogSurfaceStyles.styles.ts
Outdated
Show resolved
Hide resolved
0a3fb6a to
a679925
Compare
...es/react-components/react-dialog/library/src/components/DialogSurface/DialogSurface.types.ts
Outdated
Show resolved
Hide resolved
435eb52 to
d928a03
Compare
d928a03 to
c08be81
Compare
There was a problem hiding this comment.
I don't have comments to the PR itself, it's LGTM. However, I am unsure that it's the right fix for #35653. I got the point about explicit control, but it's not was reported in the original issue.
The root cause is:
const isNestedDialog = useHasParentContext(DialogContext);And as OverlayDrawer renders Dialog, we get this "false positive". I propose to create a separate boolean-based (or enum-based) context that controls behavior of backdrop, so OverlayDrawer can override its value with false or transparent.
We can also consider adding a new property to an existing DialogContext, but IMO it will be more complex to override it in OverlayDrawer.
@mainframev @dmytrokirpa WDYT?
Good point. We can add that and keep both, Dialog context for controlling backdrop in OverlayDrawer will be a default fixing the issue, explicit override via slot is still a good way for one-off override without using a provider, if user wants to opt-out from nested dialogs context check |
…mmed nested dialogs
…ort appearance prop
5573c54 to
dff217f
Compare
|
|
||
| export const useDialogBackdropContext_unstable = (isNestedDialog: boolean): DialogBackdropContextValue => { | ||
| const backdropOverride = React.useContext(DialogBackdropContext); | ||
| return backdropOverride !== undefined ? backdropOverride : isNestedDialog; |
There was a problem hiding this comment.
Let's avoid any logic in context hooks

This pull request introduces a new
appearanceproperty to theDialogSurfacebackdropslot in@fluentui/react-dialog, enabling explicit control over the dialog's backdrop appearance. By default, the dialog automatically chooses between a dimmed or transparent backdrop based on its nesting context, but this change allows developers to override that behavior. The update includes type definitions, logic for resolving the backdrop appearance, style adjustments, documentation, and a new story demonstrating the feature.DialogBackdropSlotPropstype to support anappearanceprop ('dimmed'or'transparent') for the backdrop slot inDialogSurface.Previous Behavior
The dimmed background applied based on the Dialog context. Inside OverlayDrawer dialogs become nested and inner Dialog does not have dimmed background. The only way to apply the dimmed background for inner Dialog is via
backdropslot inDialogSurfaceNew Behavior
Can be controlled via
backdropAppearancewithout the need to use hack with passing custom styled backdrop toDialogSurfaceRelated Issue(s)
Related older discussion