Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
a259627
feat: implement motion for Drawer
marcosmoura Jun 2, 2023
a536462
feat: add events based on presence state
marcosmoura Jun 4, 2023
77ca96d
docs: create motion documentation
marcosmoura Jun 4, 2023
8a885d1
docs: add custom motion docs
marcosmoura Jun 4, 2023
88def1b
feat: make transition duration based on drawer size
marcosmoura Jun 4, 2023
010b9fd
dcos: add missing non-modal example
marcosmoura Jun 4, 2023
a282740
docs: improve documentation examples to align with motion
marcosmoura Jun 4, 2023
7cd0c8b
fix: generate api
marcosmoura Jun 4, 2023
2e31660
fix: improve imports/exports
marcosmoura Jun 4, 2023
68eab21
fix: improve imports/exports
marcosmoura Jun 4, 2023
251dbd6
fix: add missing changefiles
marcosmoura Jun 4, 2023
f3a79d2
refactor: improve overall performance of usePresenceState
marcosmoura Jun 5, 2023
182ea1c
fix: restore styles
marcosmoura Jun 5, 2023
318e9be
fix: improve typings of usePresenceState
marcosmoura Jun 5, 2023
e91ea3e
feat: refactor motion hooks to not fire multiple transition events
marcosmoura Jun 5, 2023
d7061f9
fix: wrong imports inside stories
marcosmoura Jun 5, 2023
892c4ff
fix: use safe timeout
marcosmoura Jun 5, 2023
580c895
fix: move hook to a dedicated folder
marcosmoura Jun 5, 2023
dcd6043
feat: cache styles to only read it when ref changes
marcosmoura Jun 6, 2023
d20cece
feat: improve documentation
marcosmoura Jun 6, 2023
8978acf
feat: generate API
marcosmoura Jun 6, 2023
0cb7d13
docs: add better documentation for the hook
marcosmoura Jun 6, 2023
2fafeae
fix: rename variables for better naming
marcosmoura Jun 6, 2023
0b5f2f6
feat: make transitionPresence hook available in react-utilities and a…
marcosmoura Jun 6, 2023
8937475
fix: add missing changefiles
marcosmoura Jun 6, 2023
53ef031
Merge branch 'master' into feat/drawer-motion
marcosmoura Jun 6, 2023
b9db84b
fix: expose fewer data to state
marcosmoura Jun 6, 2023
8944102
fix: rename variable
marcosmoura Jun 7, 2023
1be28ce
feat: support css animations as well
marcosmoura Jun 7, 2023
3403a69
fix: make sure object exists before calling
marcosmoura Jun 7, 2023
d003320
fix: remove console.log
marcosmoura Jun 7, 2023
e1c0990
fix: rename useTransitionPresence to useMotionPresence
marcosmoura Jun 7, 2023
5fa9082
fix: make possible to override and remove transitions
marcosmoura Jun 13, 2023
d1292a7
Merge branch 'master' into feat/drawer-motion
marcosmoura Jun 13, 2023
a07be56
fix: remove redundant types
marcosmoura Jun 13, 2023
dbf907a
Merge branch 'master' into feat/drawer-motion
marcosmoura Jun 13, 2023
b000438
docs: add toggle button
marcosmoura Jun 13, 2023
3e9cb0e
fix: remove redundant types
marcosmoura Jun 13, 2023
9f3fc91
Merge branch 'master' into feat/drawer-motion
marcosmoura Jun 20, 2023
38e7bc6
fix: regenerate API files
marcosmoura Jun 20, 2023
d2df033
Merge branch 'master' into feat/drawer-motion
marcosmoura Jun 22, 2023
a1d9623
Merge branch 'master' into feat/drawer-motion
marcosmoura Jun 22, 2023
27accc9
docs: regenerate API
marcosmoura Jun 22, 2023
fd8edd5
docs: remove testing class
marcosmoura Jun 22, 2023
b97fe45
feat: syncronize the root/backdrop transition duration
marcosmoura Jun 28, 2023
31c97b8
Merge branch 'master' into feat/drawer-motion
marcosmoura Jul 18, 2023
ddae7e1
Merge branch 'master' into feat/drawer-motion
marcosmoura Jul 18, 2023
c6c9711
Merge branch 'master' into feat/drawer-motion
marcosmoura Jul 25, 2023
0717cd9
refactor: simplify logic and use computedStyleMap if browser supports it
marcosmoura Jul 27, 2023
f08ba00
fix: calculate transition/animation delays in pairs
marcosmoura Jul 27, 2023
56f2638
fix: calculate transition/animation delays in pairs
marcosmoura Jul 27, 2023
0f437db
fix: rename param
marcosmoura Jul 27, 2023
0c98289
feat: add unmounted state and initial tests
marcosmoura Jul 27, 2023
4dd835b
feat: add flag to prevent element to animate on first render
marcosmoura Jul 31, 2023
da7a182
fix: add more tests and fix "animateOnFirstMount" not working when tr…
marcosmoura Jul 31, 2023
6a4d05f
fix: add timer explanation
marcosmoura Jul 31, 2023
d2287fc
fix: improve TS types/docs and simplify logic
marcosmoura Aug 1, 2023
b2d98bb
fix: add transition to box-shadow to prevent glitchy exit animation
marcosmoura Aug 1, 2023
71a0c25
fix: conflicts
marcosmoura Aug 1, 2023
1faa4c8
feat: implement useMotionPresence hook
marcosmoura Aug 1, 2023
230e273
docs: add missing change files
marcosmoura Aug 1, 2023
992cdc7
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 1, 2023
5da0258
fix: simplify backdrop slot code
marcosmoura Aug 2, 2023
b8128e7
fix: improve performance of duration calculation
marcosmoura Aug 2, 2023
c721171
feat: implement useAnimationFrame hook to help controlling the motion…
marcosmoura Aug 3, 2023
6bbf319
fix: improve type definition to avoid typecast
marcosmoura Aug 3, 2023
44b58d5
fix: return a blank style declaration in case global "window" do not …
marcosmoura Aug 3, 2023
b3124d6
fix: regenerate API
marcosmoura Aug 3, 2023
caef0bd
fix: regenerate API
marcosmoura Aug 3, 2023
8234217
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 3, 2023
ac4e941
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 3, 2023
8fa8f4a
revert: use RefCallback instead of Ref
marcosmoura Aug 3, 2023
45ac91f
fix: regenerate API
marcosmoura Aug 3, 2023
2497b77
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 3, 2023
cceb832
fix: regenerate API
marcosmoura Aug 3, 2023
91cdd11
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 7, 2023
2e5f04b
docs: improve examples
marcosmoura Aug 3, 2023
f1270bb
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 7, 2023
6061b95
feat: simplify logic of useMotionPresence
marcosmoura Aug 7, 2023
d3cbded
feat: simplify API by removing redundant prop
marcosmoura Aug 7, 2023
28fecae
feat: implement useMotion hook instead of useMotionPresence
marcosmoura Aug 17, 2023
003dab8
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 17, 2023
ba8e3fd
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 17, 2023
cfea341
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 17, 2023
ab9ff66
feat: implement useMotion hook instead of useMotionPresence
marcosmoura Aug 17, 2023
76d1b82
feat: remove useMotionPresence hook
marcosmoura Aug 17, 2023
7fd87f9
fix: remove old changefile
marcosmoura Aug 17, 2023
1e16743
feat: expose useAnimationFrame hook
marcosmoura Aug 17, 2023
41e9e8c
fix: add missing changefile
marcosmoura Aug 17, 2023
647b9e5
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 17, 2023
f384b82
fix: mismatch dependencies
marcosmoura Aug 17, 2023
ce4d183
feat: add motion docs to public site
marcosmoura Aug 17, 2023
05ba7e1
docs: add documentatio for the hook
marcosmoura Aug 17, 2023
5524088
chore: motion with slots
bsunderhus Aug 18, 2023
2068001
feat: implement useMotionFromSlot to better resolve slots with motion…
marcosmoura Aug 20, 2023
1577e9a
feat: create method canRender
marcosmoura Aug 20, 2023
311f5e6
feat: only apply internal motion classes in case no external motion i…
marcosmoura Aug 21, 2023
d76e3df
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 21, 2023
f2f976e
fix: mismatch dependencies and regenerate API files
marcosmoura Aug 21, 2023
233c8bc
feat: add missing change files
marcosmoura Aug 21, 2023
feeacab
fix: misc little fixes
marcosmoura Aug 21, 2023
7cf6886
fix: misc perf fixes
marcosmoura Aug 21, 2023
392eff5
feat: make react-motion-preview public
marcosmoura Aug 21, 2023
e9e8bbe
feat: create useMotion hook accepting either a boolean or motion state
marcosmoura Aug 21, 2023
9152d81
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 21, 2023
3872d0a
fix: upgrade stories to use latest changes to hook
marcosmoura Aug 21, 2023
d8cdb72
feat: create useMotionStyles to make it easier motion styles to any c…
marcosmoura Aug 21, 2023
6debd98
feat: make package public
marcosmoura Aug 21, 2023
7f27429
fix: add missing change file
marcosmoura Aug 21, 2023
9593026
fix: join two related hooks in one file to be easier to test
marcosmoura Aug 21, 2023
fd9970f
fix: remove unused imports
marcosmoura Aug 21, 2023
5cb0a56
docs: move stories to public site
marcosmoura Aug 21, 2023
92ecfed
docs: add title to example
marcosmoura Aug 21, 2023
190493f
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 21, 2023
9086d1a
fix: remove leftover property
marcosmoura Aug 22, 2023
969ce87
fix: add type to improve useMemo
marcosmoura Aug 22, 2023
32d4144
fix: use correct import paths
marcosmoura Aug 22, 2023
1d8e9b8
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 22, 2023
c437db6
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 22, 2023
f09ff57
feat: use boolean instead of function
marcosmoura Aug 22, 2023
e6bb24b
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 23, 2023
a1616d2
fix: remove outdated changefile
marcosmoura Aug 23, 2023
74b8257
fix: use correct boolean values
marcosmoura Aug 23, 2023
7942e80
fix: improve typings and documentation
marcosmoura Aug 23, 2023
2d89ef2
Merge branch 'master' into feat/use-motion-presence-hook
marcosmoura Aug 23, 2023
e869087
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 23, 2023
e88d95a
Merge branch 'feat/use-motion-presence-hook' into feat/drawer-motion
marcosmoura Aug 23, 2023
7606af3
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 28, 2023
b37b106
Discard changes to packages/react-charting/src/components/AreaChart/A…
marcosmoura Aug 28, 2023
48c370e
Discard changes to packages/react-charting/src/components/HorizontalB…
marcosmoura Aug 28, 2023
e98ca40
Discard changes to packages/react-charting/src/components/StackedBarC…
marcosmoura Aug 28, 2023
4b27637
Discard changes to packages/react-charting/src/components/LineChart/L…
marcosmoura Aug 28, 2023
74f6a08
Discard changes to packages/react-charting/src/components/StackedBarC…
marcosmoura Aug 28, 2023
fa92c7f
Merge branch 'master' into feat/drawer-motion
marcosmoura Aug 28, 2023
58b1e52
Merge branch 'master' into feat/drawer-motion
marcosmoura Sep 3, 2023
491c0df
Discard changes to .github/CODEOWNERS
marcosmoura Sep 3, 2023
dd3cf56
Discard changes to apps/vr-tests/src/stories/react-charting/StackedBa…
marcosmoura Sep 3, 2023
ccf1188
Discard changes to packages/react-components/react-drawer/stories/Dra…
marcosmoura Sep 3, 2023
482064c
Discard changes to packages/react-components/react-drawer/stories/Dra…
marcosmoura Sep 3, 2023
88180b4
Discard changes to packages/react-components/react-motion-preview/src…
marcosmoura Sep 3, 2023
02baa6c
Discard changes to packages/react-components/react-motion-preview/sto…
marcosmoura Sep 3, 2023
d4a3b04
Merge branch 'master' into feat/drawer-motion
marcosmoura Oct 4, 2023
cad2b49
upgrade styles
marcosmoura Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: make useTransitionPresence hook",
"packageName": "@fluentui/react-components",
"email": "marcosvmmoura@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add motion to dialog",
"packageName": "@fluentui/react-dialog",
"email": "marcosvmmoura@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "feat: add transition on open/close",
"packageName": "@fluentui/react-drawer",
"email": "marcosvmmoura@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: make useTransitionPresence hook",
"packageName": "@fluentui/react-utilities",
"email": "marcosvmmoura@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ import { useMenuTriggerContext_unstable } from '@fluentui/react-menu';
import { useMergedRefs } from '@fluentui/react-utilities';
import { useModalAttributes } from '@fluentui/react-tabster';
import { UseModalAttributesOptions } from '@fluentui/react-tabster';
import { useMotionPresence } from '@fluentui/react-utilities';
import { UseMotionPresenceEvents } from '@fluentui/react-utilities';
import { UseMotionPresenceState } from '@fluentui/react-utilities';
import { useObservedElement } from '@fluentui/react-tabster';
import { useOption_unstable } from '@fluentui/react-combobox';
import { useOptionGroup_unstable } from '@fluentui/react-combobox';
Expand Down Expand Up @@ -3459,6 +3462,12 @@ export { useModalAttributes }

export { UseModalAttributesOptions }

export { useMotionPresence }

export { UseMotionPresenceEvents }

export { UseMotionPresenceState }

export { useObservedElement }

export { useOption_unstable }
Expand Down
15 changes: 11 additions & 4 deletions packages/react-components/react-dialog/etc/react-dialog.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import { ARIAButtonType } from '@fluentui/react-aria';
import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import { ContextSelector } from '@fluentui/react-context-selector';
import type { ExtractSlotProps } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { JSXElementConstructor } from 'react';
import { MotionShorthand } from '@fluentui/react-motion-preview';
import { MotionState } from '@fluentui/react-motion-preview';
import type { PortalProps } from '@fluentui/react-portal';
import { Provider } from 'react';
import * as React_2 from 'react';
Expand Down Expand Up @@ -84,7 +87,8 @@ export type DialogContentState = ComponentState<DialogContentSlots>;

// @public (undocumented)
export type DialogContextValue = {
open: boolean;
open: MotionShorthand<DialogSurfaceElement>;
motion: MotionState<DialogSurfaceElement>;
inertTrapFocus: boolean;
dialogTitleId?: string;
isNestedDialog: boolean;
Expand Down Expand Up @@ -117,7 +121,7 @@ export type DialogOpenChangeEventHandler = (event: DialogOpenChangeEvent, data:
// @public (undocumented)
export type DialogProps = ComponentProps<Partial<DialogSlots>> & {
modalType?: DialogModalType;
open?: boolean;
open?: MotionShorthand<DialogSurfaceElement>;
defaultOpen?: boolean;
onOpenChange?: DialogOpenChangeEventHandler;
children: [JSX.Element, JSX.Element] | JSX.Element;
Expand Down Expand Up @@ -156,12 +160,15 @@ export const DialogSurfaceProvider: Provider<boolean | undefined>;

// @public (undocumented)
export type DialogSurfaceSlots = {
backdrop?: Slot<'div'>;
backdrop?: Slot<DialogBackdropProps>;
root: Slot<'div'>;
};

// @public
export type DialogSurfaceState = ComponentState<DialogSurfaceSlots> & Pick<PortalProps, 'mountNode'>;
export type DialogSurfaceState = ComponentState<DialogSurfaceSlots> & {
motion: MotionState<DialogSurfaceElement>;
backdropMotion: MotionState<DialogSurfaceElement>;
} & Pick<PortalProps, 'mountNode'>;

// @public
export const DialogTitle: ForwardRefComponent<DialogTitleProps>;
Expand Down
11 changes: 6 additions & 5 deletions packages/react-components/react-dialog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@
"@fluentui/scripts-tasks": "*"
},
"dependencies": {
"@fluentui/react-utilities": "^9.13.5",
"@fluentui/react-jsx-runtime": "^9.0.12",
"@fluentui/keyboard-keys": "^9.0.6",
"@fluentui/react-context-selector": "^9.1.36",
"@fluentui/react-shared-contexts": "^9.9.2",
"@fluentui/react-aria": "^9.3.38",
"@fluentui/react-context-selector": "^9.1.36",
"@fluentui/react-icons": "^2.0.217",
"@fluentui/react-jsx-runtime": "^9.0.3",
"@fluentui/react-motion-preview": "0.2.10",
"@fluentui/react-portal": "^9.3.9",
"@fluentui/react-shared-contexts": "^9.9.2",
"@fluentui/react-tabster": "^9.13.2",
"@fluentui/react-theme": "^9.1.14",
"@fluentui/react-portal": "^9.3.19",
"@fluentui/react-utilities": "^9.13.5",
"@griffel/react": "^1.5.14",
"@swc/helpers": "^0.5.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type * as React from 'react';
import type { ComponentProps, ComponentState } from '@fluentui/react-utilities';
import type { DialogContextValue, DialogSurfaceContextValue } from '../../contexts';
import type { DialogSurfaceElement } from '../DialogSurface/DialogSurface.types';
import type { MotionShorthand } from '@fluentui/react-motion-preview';

export type DialogSlots = {};

Expand Down Expand Up @@ -68,7 +69,7 @@ export type DialogProps = ComponentProps<Partial<DialogSlots>> & {
* Controls the open state of the dialog
* @default false
*/
open?: boolean;
open?: MotionShorthand<DialogSurfaceElement>;
/**
* Default value for the uncontrolled open state of the dialog.
* @default false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DialogContext } from '../../contexts';

import type { DialogOpenChangeData, DialogProps, DialogState } from './Dialog.types';
import { useModalAttributes } from '@fluentui/react-tabster';
import { useMotion } from '@fluentui/react-motion-preview';

/**
* Create the state required to render Dialog.
Expand All @@ -26,6 +27,8 @@ export const useDialog_unstable = (props: DialogProps): DialogState => {
initialState: false,
});

const motion = useMotion(open);

const requestOpenChange = useEventCallback((data: DialogOpenChangeData) => {
onOpenChange?.(data.event, data);

Expand All @@ -36,7 +39,7 @@ export const useDialog_unstable = (props: DialogProps): DialogState => {
}
});

const focusRef = useFocusFirstElement(open, modalType);
const focusRef = useFocusFirstElement(motion.canRender, modalType);
const disableBodyScroll = useDisableBodyScroll();
const isBodyScrollLocked = Boolean(open && modalType !== 'non-modal');

Expand All @@ -52,13 +55,12 @@ export const useDialog_unstable = (props: DialogProps): DialogState => {
});

return {
components: {
backdrop: 'div',
},
inertTrapFocus,
open,
motion,
components: {},
inertTrapFocus,
modalType,
content: open ? content : null,
content: motion.canRender ? content : null,
trigger,
requestOpenChange,
dialogTitleId: useId('dialog-title-'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import type { DialogContextValues, DialogState } from './Dialog.types';

export function useDialogContextValues_unstable(state: DialogState): DialogContextValues {
const {
modalType,
open,
dialogRef,
dialogTitleId,
isNestedDialog,
inertTrapFocus,
requestOpenChange,
isNestedDialog,
modalAttributes,
modalType,
motion,
open,
requestOpenChange,
triggerAttributes,
} = state;

Expand All @@ -19,15 +20,16 @@ export function useDialogContextValues_unstable(state: DialogState): DialogConte
* there is no sense to memoize it
*/
const dialog: DialogContextValue = {
open,
modalType,
dialogRef,
dialogTitleId,
isNestedDialog,
inertTrapFocus,
isNestedDialog,
modalAttributes,
triggerAttributes,
modalType,
motion,
open,
requestOpenChange,
triggerAttributes,
};

const dialogSurface: DialogSurfaceContextValue = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
import type { ComponentProps, ComponentState, ExtractSlotProps, Slot } from '@fluentui/react-utilities';
import type { PortalProps } from '@fluentui/react-portal';
import { DialogSurfaceContextValue } from '../../contexts';
import { MotionShorthand, MotionState } from '@fluentui/react-motion-preview';

export type DialogBackdropProps = ExtractSlotProps<Slot<'div'>> & {
motion?: MotionShorthand<HTMLDivElement>;
};

export type DialogSurfaceSlots = {
/**
Expand All @@ -10,7 +15,7 @@ export type DialogSurfaceSlots = {
* The backdrop should have `aria-hidden="true"`.
*
*/
backdrop?: Slot<'div'>;
backdrop?: Slot<DialogBackdropProps>;
root: Slot<'div'>;
};

Expand All @@ -31,4 +36,7 @@ export type DialogSurfaceContextValues = {
/**
* State used in rendering DialogSurface
*/
export type DialogSurfaceState = ComponentState<DialogSurfaceSlots> & Pick<PortalProps, 'mountNode'>;
export type DialogSurfaceState = ComponentState<DialogSurfaceSlots> &
Pick<PortalProps, 'mountNode'> & {
motion: MotionState<DialogSurfaceElement>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
isResolvedShorthand,
slot,
} from '@fluentui/react-utilities';
import type { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';
import { DialogSurfaceElement, DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.types';
import { useDialogContext_unstable } from '../../contexts';
import { Escape } from '@fluentui/keyboard-keys';

Expand All @@ -26,7 +26,7 @@ export const useDialogSurface_unstable = (
const modalType = useDialogContext_unstable(ctx => ctx.modalType);
const modalAttributes = useDialogContext_unstable(ctx => ctx.modalAttributes);
const dialogRef = useDialogContext_unstable(ctx => ctx.dialogRef);
const open = useDialogContext_unstable(ctx => ctx.open);
const motion = useDialogContext_unstable(ctx => ctx.motion);
const requestOpenChange = useDialogContext_unstable(ctx => ctx.requestOpenChange);
const dialogTitleID = useDialogContext_unstable(ctx => ctx.dialogTitleId);

Expand Down Expand Up @@ -58,16 +58,20 @@ export const useDialogSurface_unstable = (
}
});

const backdrop = slot.optional(props.backdrop, {
renderByDefault: open && modalType !== 'non-modal',
defaultProps: {
'aria-hidden': 'true',
},
elementType: 'div',
});
const backdrop =
motion.canRender && modalType !== 'non-modal'
? slot.optional(props.backdrop, {
defaultProps: {
'aria-hidden': 'true',
},
elementType: 'div',
})
: undefined;

if (backdrop) {
backdrop.onClick = handledBackdropClick;
}

return {
components: { backdrop: 'div', root: 'div' },
backdrop,
Expand All @@ -81,9 +85,11 @@ export const useDialogSurface_unstable = (
...props,
...modalAttributes,
onKeyDown: handleKeyDown,
ref: useMergedRefs(ref, dialogRef),
ref: useMergedRefs(ref, dialogRef, motion.ref),
}),
{ elementType: 'div' },
),

motion,
};
};
Loading