Skip to content

Add TransitionProps prop to <Dialog /> component #3552

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions packages/@headlessui-react/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
} from '../description/description'
import { FocusTrap, FocusTrapFeatures } from '../focus-trap/focus-trap'
import { Portal, PortalGroup, useNestedPortals } from '../portal/portal'
import { Transition, TransitionChild } from '../transition/transition'
import { Transition, TransitionChild, type TransitionRootProps } from '../transition/transition'

enum DialogStates {
Open,
Expand Down Expand Up @@ -347,6 +347,7 @@ export type DialogProps<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG> =
role?: 'dialog' | 'alertdialog'
autoFocus?: boolean
transition?: boolean
TransitionProps?: TransitionRootProps
__demoMode?: boolean
}
>
Expand All @@ -355,7 +356,7 @@ function DialogFn<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG>(
props: DialogProps<TTag>,
ref: Ref<HTMLElement>
) {
let { transition = false, open, ...rest } = props
let { TransitionProps, open, transition = false, ...rest } = props

// Validations
let usesOpenClosedState = useOpenClosed()
Expand Down Expand Up @@ -395,7 +396,7 @@ function DialogFn<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG>(
if ((open !== undefined || transition) && !rest.static) {
return (
<MainTreeProvider>
<Transition show={open} transition={transition} unmount={rest.unmount}>
<Transition show={open} transition={transition} unmount={rest.unmount} {...TransitionProps}>
<InternalDialog ref={ref} {...rest} />
</Transition>
</MainTreeProvider>
Expand Down