File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
packages/core/src/components/Modal/Modal Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -115,14 +115,13 @@ const Modal = forwardRef(
115
115
style = { zIndexStyle }
116
116
/>
117
117
< FocusLockComponent returnFocus >
118
- < RemoveScroll forwardProps >
118
+ < RemoveScroll forwardProps ref = { ref } >
119
119
< motion . div
120
120
variants = { modalAnimationVariants }
121
121
initial = "exit"
122
122
animate = "enter"
123
123
exit = "exit"
124
124
custom = { anchorElementRef }
125
- ref = { ref }
126
125
className = { cx (
127
126
styles . modal ,
128
127
getStyle ( styles , camelCase ( "size-" + size ) ) ,
Original file line number Diff line number Diff line change @@ -61,6 +61,19 @@ describe("Modal", () => {
61
61
expect ( getByText ( "My content" ) ) . toBeInTheDocument ( ) ;
62
62
} ) ;
63
63
64
+ it ( "ensures the ref prop does not return null when modal is shown" , ( ) => {
65
+ const ref = React . createRef < HTMLDivElement > ( ) ;
66
+
67
+ const { getByTestId } = render (
68
+ < Modal id = { id } show ref = { ref } data-testid = "modal" >
69
+ < div > Content</ div >
70
+ </ Modal >
71
+ ) ;
72
+
73
+ expect ( getByTestId ( "modal" ) ) . toBeInTheDocument ( ) ;
74
+ expect ( ref . current ) . not . toBeNull ( ) ;
75
+ } ) ;
76
+
64
77
it ( "applies default size as 'medium' when not supplied with a size" , ( ) => {
65
78
const { getByRole } = render (
66
79
< Modal id = { id } show >
You can’t perform that action at this time.
0 commit comments