File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,9 +28,16 @@ class Modal extends React.PureComponent<ModalProps> {
2828 document . body . style . position = 'relative' ;
2929 document . body . style . height = 'initial' ;
3030 document . body . style . minHeight = 'initial' ;
31+
3132 this . modalRoot . appendChild ( this . el ) ;
3233 }
3334
35+ public componentDidUpdate ( ) {
36+ const { visible, isScrollable = false } = this . props ;
37+ if ( visible && ! isScrollable ) document . body . style . overflow = 'hidden' ;
38+ else document . body . style . overflow = '' ;
39+ }
40+
3441 public componentWillUnmount ( ) {
3542 this . modalRoot . removeChild ( this . el ) ;
3643 }
@@ -47,10 +54,6 @@ class Modal extends React.PureComponent<ModalProps> {
4754 public render ( ) {
4855 const { transparent, visible, isScrollable = false } = this . props ;
4956
50- // Prevent body scroll
51- if ( visible && ! isScrollable ) document . body . style . overflow = 'hidden' ;
52- // Reset to normal
53- if ( ! visible ) document . body . style . overflow = '' ;
5457 if ( ! visible ) return null ;
5558
5659 return ReactDOM . createPortal (
You can’t perform that action at this time.
0 commit comments