Skip to content

Commit

Permalink
fix type of dialog's initial-focus-ref prop (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvice authored Jan 8, 2024
1 parent c4e4782 commit e22baa2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/dialog/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dialog as HeadlessDialog } from '@headlessui/react'
import classNames from 'classnames'
import { ReactElement, useRef } from 'react'
import { MutableRefObject, ReactElement, useRef } from 'react'
import { useTheme } from '../../../framework'
import { ClassNameProps } from '../../types'
import { DialogContext } from '../DialogContext'
Expand All @@ -9,7 +9,7 @@ import { DialogPosition, DialogSize } from '../types'
export type DialogProps = ClassNameProps & {
isOpen?: boolean
onDismiss?: () => void
initialFocusRef?: React.RefObject<HTMLDivElement>
initialFocusRef?: MutableRefObject<HTMLElement | null>
size?: DialogSize
children?: ReactElement
mobilePosition?: DialogPosition
Expand All @@ -32,8 +32,8 @@ export function Dialog({
...props
}: DialogProps): ReactElement {
const { dialog } = useTheme()
const nullRef = useRef<HTMLDivElement>(null)
const initialFocusRef = initialFocusRefProp ?? nullRef
const panelRef = useRef<HTMLDivElement>(null)
const initialFocusRef = initialFocusRefProp ?? panelRef

return (
<DialogContext.Provider value={{ size }}>
Expand All @@ -50,7 +50,7 @@ export function Dialog({
{...props}
>
<HeadlessDialog.Panel
ref={initialFocusRef}
ref={panelRef}
aria-label={ariaLabel}
className={classNames(
dialog.dialog.base,
Expand Down

0 comments on commit e22baa2

Please sign in to comment.