@@ -152,7 +152,7 @@ describe('modal', () => {
152
152
( ) => {
153
153
expect ( queryByTestId ( 'modal' ) ) . not . toBeInTheDocument ( ) ;
154
154
} ,
155
- { timeout : 10 }
155
+ { timeout : 1 }
156
156
) ;
157
157
158
158
expect ( document . documentElement . style . position ) . toBe ( '' ) ;
@@ -200,7 +200,7 @@ describe('modal', () => {
200
200
( ) => {
201
201
expect ( queryByText ( / s e c o n d m o d a l / ) ) . not . toBeInTheDocument ( ) ;
202
202
} ,
203
- { timeout : 10 }
203
+ { timeout : 1 }
204
204
) ;
205
205
expect ( document . documentElement . style . position ) . toBe ( 'fixed' ) ;
206
206
@@ -221,7 +221,42 @@ describe('modal', () => {
221
221
( ) => {
222
222
expect ( queryByText ( / f i r s t m o d a l / ) ) . not . toBeInTheDocument ( ) ;
223
223
} ,
224
- { timeout : 10 }
224
+ { timeout : 1 }
225
+ ) ;
226
+ expect ( document . documentElement . style . position ) . toBe ( '' ) ;
227
+ } ) ;
228
+
229
+ it ( 'should unblock scroll when one modal is closed and the one still open has blockScroll set to false' , async ( ) => {
230
+ const { rerender, getAllByTestId, queryByText } = render (
231
+ < React . Fragment >
232
+ < Modal open blockScroll = { false } onClose = { ( ) => null } >
233
+ < div > first modal</ div >
234
+ </ Modal >
235
+ < Modal open onClose = { ( ) => null } >
236
+ < div > second modal</ div >
237
+ </ Modal >
238
+ </ React . Fragment >
239
+ ) ;
240
+ expect ( document . documentElement . style . position ) . toBe ( 'fixed' ) ;
241
+
242
+ // We close one modal, the scroll should be unlocked as remaining modal is not locking the scroll
243
+ rerender (
244
+ < React . Fragment >
245
+ < Modal open blockScroll = { false } onClose = { ( ) => null } >
246
+ < div > first modal</ div >
247
+ </ Modal >
248
+ < Modal open = { false } onClose = { ( ) => null } >
249
+ < div > second modal</ div >
250
+ </ Modal >
251
+ </ React . Fragment >
252
+ ) ;
253
+
254
+ fireEvent . animationEnd ( getAllByTestId ( 'overlay' ) [ 1 ] ) ;
255
+ await waitFor (
256
+ ( ) => {
257
+ expect ( queryByText ( / s e c o n d m o d a l / ) ) . not . toBeInTheDocument ( ) ;
258
+ } ,
259
+ { timeout : 1 }
225
260
) ;
226
261
expect ( document . documentElement . style . position ) . toBe ( '' ) ;
227
262
} ) ;
0 commit comments