File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
packages/coreui-react/src/components/modal Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,12 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
171
171
useLayoutEffect ( ( ) => {
172
172
if ( _visible ) {
173
173
document . body . classList . add ( 'modal-open' )
174
+
175
+ if ( backdrop ) {
176
+ document . body . style . overflow = 'hidden'
177
+ document . body . style . paddingRight = '0px'
178
+ }
179
+
174
180
setTimeout (
175
181
( ) => {
176
182
modalRef . current ?. focus ( )
@@ -179,8 +185,19 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
179
185
)
180
186
} else {
181
187
document . body . classList . remove ( 'modal-open' )
188
+
189
+ if ( backdrop ) {
190
+ document . body . style . removeProperty ( 'overflow' )
191
+ document . body . style . removeProperty ( 'padding-right' )
192
+ }
193
+ }
194
+ return ( ) => {
195
+ document . body . classList . remove ( 'modal-open' )
196
+ if ( backdrop ) {
197
+ document . body . style . removeProperty ( 'overflow' )
198
+ document . body . style . removeProperty ( 'padding-right' )
199
+ }
182
200
}
183
- return ( ) => document . body . classList . remove ( 'modal-open' )
184
201
} , [ _visible ] )
185
202
186
203
const handleClickOutside = ( event : Event ) => {
You can’t perform that action at this time.
0 commit comments