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 {
26
26
// TODO refactor: pass z-indices config on app level: https://vanilla-extract.style/documentation/packages/dynamic/
27
27
zIndex ?: number ;
28
28
}
29
-
30
- export const Root = ( {
29
+ /*
30
+ export const Root = React.forwardRef( ({
31
31
open,
32
32
setOpen,
33
33
onCloseAutoFocusRef,
34
34
children,
35
35
portalContainer,
36
36
zIndex,
37
- } : Readonly < DialogRootProps > ) : JSX . Element => (
37
+ }: Readonly<DialogRootProps>, ref) ): JSX.Element => (
38
38
<AlertDialog.Root open={open}>
39
39
<AlertDialog.Portal container={portalContainer}>
40
40
<AlertDialog.Overlay asChild>
@@ -62,3 +62,45 @@ export const Root = ({
62
62
</AlertDialog.Portal>
63
63
</AlertDialog.Root>
64
64
);
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