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>(
171171 useLayoutEffect ( ( ) => {
172172 if ( _visible ) {
173173 document . body . classList . add ( 'modal-open' )
174+
175+ if ( backdrop ) {
176+ document . body . style . overflow = 'hidden'
177+ document . body . style . paddingRight = '0px'
178+ }
179+
174180 setTimeout (
175181 ( ) => {
176182 modalRef . current ?. focus ( )
@@ -179,8 +185,19 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
179185 )
180186 } else {
181187 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+ }
182200 }
183- return ( ) => document . body . classList . remove ( 'modal-open' )
184201 } , [ _visible ] )
185202
186203 const handleClickOutside = ( event : Event ) => {
You can’t perform that action at this time.
0 commit comments