@@ -105,7 +105,7 @@ describe('modal', () => {
105
105
< div > modal content</ div >
106
106
</ Modal >
107
107
) ;
108
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
108
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
109
109
} ) ;
110
110
111
111
it ( 'should block the scroll when modal is rendered open' , ( ) => {
@@ -114,7 +114,7 @@ describe('modal', () => {
114
114
< div > modal content</ div >
115
115
</ Modal >
116
116
) ;
117
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
117
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
118
118
} ) ;
119
119
120
120
it ( 'should block scroll when prop open change to true' , ( ) => {
@@ -123,14 +123,14 @@ describe('modal', () => {
123
123
< div > modal content</ div >
124
124
</ Modal >
125
125
) ;
126
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
126
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
127
127
128
128
rerender (
129
129
< Modal open = { true } onClose = { ( ) => null } >
130
130
< div > modal content</ div >
131
131
</ Modal >
132
132
) ;
133
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
133
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
134
134
} ) ;
135
135
136
136
it ( 'should unblock scroll when prop open change to false' , async ( ) => {
@@ -139,7 +139,7 @@ describe('modal', () => {
139
139
< div > modal content</ div >
140
140
</ Modal >
141
141
) ;
142
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
142
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
143
143
144
144
rerender (
145
145
< Modal open = { false } onClose = { ( ) => null } animationDuration = { 0 } >
@@ -155,7 +155,7 @@ describe('modal', () => {
155
155
{ timeout : 1 }
156
156
) ;
157
157
158
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
158
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
159
159
} ) ;
160
160
161
161
it ( 'should unblock scroll when unmounted directly' , async ( ) => {
@@ -164,10 +164,10 @@ describe('modal', () => {
164
164
< div > modal content</ div >
165
165
</ Modal >
166
166
) ;
167
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
167
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
168
168
169
169
unmount ( ) ;
170
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
170
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
171
171
} ) ;
172
172
173
173
it ( 'should unblock scroll when multiple modals are opened and then closed' , async ( ) => {
@@ -181,7 +181,7 @@ describe('modal', () => {
181
181
</ Modal >
182
182
</ React . Fragment >
183
183
) ;
184
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
184
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
185
185
186
186
// We close one modal, the scroll should be locked
187
187
rerender (
@@ -202,7 +202,7 @@ describe('modal', () => {
202
202
} ,
203
203
{ timeout : 1 }
204
204
) ;
205
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
205
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
206
206
207
207
// We close the second modal, the scroll should be unlocked
208
208
rerender (
@@ -223,7 +223,7 @@ describe('modal', () => {
223
223
} ,
224
224
{ timeout : 1 }
225
225
) ;
226
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
226
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
227
227
} ) ;
228
228
229
229
it ( 'should unblock scroll when one modal is closed and the one still open has blockScroll set to false' , async ( ) => {
@@ -237,7 +237,7 @@ describe('modal', () => {
237
237
</ Modal >
238
238
</ React . Fragment >
239
239
) ;
240
- expect ( document . documentElement . style . position ) . toBe ( 'fixed ' ) ;
240
+ expect ( document . body . style . overflow ) . toBe ( 'hidden ' ) ;
241
241
242
242
// We close one modal, the scroll should be unlocked as remaining modal is not locking the scroll
243
243
rerender (
@@ -258,7 +258,7 @@ describe('modal', () => {
258
258
} ,
259
259
{ timeout : 1 }
260
260
) ;
261
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
261
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
262
262
} ) ;
263
263
} ) ;
264
264
@@ -437,7 +437,7 @@ describe('modal', () => {
437
437
< div > modal content</ div >
438
438
</ Modal >
439
439
) ;
440
- expect ( document . documentElement . style . position ) . toBe ( '' ) ;
440
+ expect ( document . body . style . overflow ) . toBe ( '' ) ;
441
441
} ) ;
442
442
} ) ;
443
443
0 commit comments