File tree Expand file tree Collapse file tree 1 file changed +45
-3
lines changed Expand file tree Collapse file tree 1 file changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -26,15 +26,15 @@ export interface DialogRootProps {
2626 // TODO refactor: pass z-indices config on app level: https://vanilla-extract.style/documentation/packages/dynamic/
2727 zIndex ?: number ;
2828}
29-
30- export const Root = ( {
29+ /*
30+ export const Root = React.forwardRef( ({
3131 open,
3232 setOpen,
3333 onCloseAutoFocusRef,
3434 children,
3535 portalContainer,
3636 zIndex,
37- } : Readonly < DialogRootProps > ) : JSX . Element => (
37+ }: Readonly<DialogRootProps>, ref) ): JSX.Element => (
3838 <AlertDialog.Root open={open}>
3939 <AlertDialog.Portal container={portalContainer}>
4040 <AlertDialog.Overlay asChild>
@@ -62,3 +62,45 @@ export const Root = ({
6262 </AlertDialog.Portal>
6363 </AlertDialog.Root>
6464);
65+ */
66+
67+ export const Root = React . forwardRef ( (
68+ props : Readonly < DialogRootProps > , forwardReference ?: any
69+ ) => {
70+ const {
71+ open,
72+ setOpen,
73+ onCloseAutoFocusRef,
74+ children,
75+ portalContainer,
76+ zIndex,
77+ } = props ;
78+ return (
79+ < AlertDialog . Root open = { open } >
80+ < AlertDialog . Portal container = { portalContainer } >
81+ < AlertDialog . Overlay asChild >
82+ < Backdrop zIndex = { zIndex } />
83+ </ AlertDialog . Overlay >
84+ < AlertDialog . Content
85+ ref = { forwardReference }
86+ asChild
87+ onEscapeKeyDown = { ( ) : void => {
88+ setOpen ( false ) ;
89+ } }
90+ onCloseAutoFocus = {
91+ onCloseAutoFocusRef &&
92+ ( ( ) : void => {
93+ onCloseAutoFocusRef . current ?. focus ( ) ;
94+ } )
95+ }
96+ >
97+ < Content
98+ className = { cx . dialogContent }
99+ style = { { zIndex : zIndex === undefined ? undefined : zIndex + 1 } }
100+ >
101+ { children }
102+ </ Content >
103+ </ AlertDialog . Content >
104+ </ AlertDialog . Portal >
105+ </ AlertDialog . Root >
106+ ) } ) ;
You can’t perform that action at this time.
0 commit comments