File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/libs/ui/lib/components/modals/base-modal Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1- import { FC , ReactNode , useEffect } from 'react'
1+ import { FC , ReactNode , useCallback , useEffect } from 'react'
22import Modal , { ModalProps } from 'react-responsive-modal'
33import classNames from 'classnames'
44
@@ -39,12 +39,20 @@ const BaseModal: FC<BaseModalProps> = (props: BaseModalProps) => {
3939 )
4040 }
4141
42+ const handleBodyScroll = useCallback ( ( force ?: boolean ) => {
43+ const isOpen = force ?? props . open
44+ document . documentElement . style . overflow = isOpen ? 'hidden' : ''
45+ document . body . style . overflow = isOpen ? 'hidden' : ''
46+ } , [ props . open ] )
47+
4248 useEffect ( ( ) => {
43- if ( ! props . blockScroll ) {
44- document . documentElement . style . overflow = props . open ? 'hidden' : ''
45- document . body . style . overflow = props . open ? 'hidden' : ''
49+ if ( props . blockScroll ) {
50+ return undefined
4651 }
47- } , [ props . blockScroll , props . open ] )
52+
53+ handleBodyScroll ( )
54+ return ( ) => handleBodyScroll ( false )
55+ } , [ handleBodyScroll , props . blockScroll , props . open ] )
4856
4957 return (
5058 < Modal
You can’t perform that action at this time.
0 commit comments