✨(frontend) pass ref to the dialog inner overlay
Needed a ref to determine the size of the opened overlay.
This commit is contained in:
committed by
aleb_the_flash
parent
11e162dbd4
commit
57bba04cf3
@@ -10,6 +10,7 @@ import {
|
|||||||
} from 'react-aria-components'
|
} from 'react-aria-components'
|
||||||
import { Div, Button, Box, VerticallyOffCenter } from '@/primitives'
|
import { Div, Button, Box, VerticallyOffCenter } from '@/primitives'
|
||||||
import { text } from './Text'
|
import { text } from './Text'
|
||||||
|
import { MutableRefObject } from 'react'
|
||||||
|
|
||||||
const StyledModalOverlay = styled(ModalOverlay, {
|
const StyledModalOverlay = styled(ModalOverlay, {
|
||||||
base: {
|
base: {
|
||||||
@@ -61,6 +62,7 @@ export type DialogProps = RACDialogProps & {
|
|||||||
*/
|
*/
|
||||||
onOpenChange?: (isOpen: boolean) => void
|
onOpenChange?: (isOpen: boolean) => void
|
||||||
type?: 'flex'
|
type?: 'flex'
|
||||||
|
innerRef?: MutableRefObject<HTMLDivElement | null>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Dialog = ({
|
export const Dialog = ({
|
||||||
@@ -69,6 +71,7 @@ export const Dialog = ({
|
|||||||
onClose,
|
onClose,
|
||||||
isOpen,
|
isOpen,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
|
innerRef,
|
||||||
...dialogProps
|
...dialogProps
|
||||||
}: DialogProps) => {
|
}: DialogProps) => {
|
||||||
const isAlert = dialogProps['role'] === 'alertdialog'
|
const isAlert = dialogProps['role'] === 'alertdialog'
|
||||||
@@ -93,7 +96,7 @@ export const Dialog = ({
|
|||||||
<VerticallyOffCenter>
|
<VerticallyOffCenter>
|
||||||
<Div margin="auto" width="fit-content" maxWidth="full">
|
<Div margin="auto" width="fit-content" maxWidth="full">
|
||||||
<Div margin="1rem" pointerEvents="auto">
|
<Div margin="1rem" pointerEvents="auto">
|
||||||
<Box size="sm" type={boxType}>
|
<Box size="sm" type={boxType} ref={innerRef}>
|
||||||
{!!title && (
|
{!!title && (
|
||||||
<Heading
|
<Heading
|
||||||
slot="title"
|
slot="title"
|
||||||
|
|||||||
Reference in New Issue
Block a user