@@ -45,6 +45,10 @@ function offset(el: any) {
4545  return  pos ; 
4646} 
4747
48+ // https://github.com/ant-design/ant-design/issues/19340 
49+ // https://github.com/ant-design/ant-design/issues/19332 
50+ let  cacheOverflow  =  { } ; 
51+ 
4852export  interface  IDialogChildProps  extends  IDialogPropTypes  { 
4953  getOpenCount : ( )  =>  number ; 
5054} 
@@ -96,7 +100,7 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
96100      // first show 
97101      if  ( ! prevProps . visible )  { 
98102        this . openTime  =  Date . now ( ) ; 
99-         this . addScrollingEffect ( ) ; 
103+         this . switchScrollingEffect ( ) ; 
100104        this . tryFocus ( ) ; 
101105        const  dialogNode  =  ReactDOM . findDOMNode ( this . dialog ) ; 
102106        if  ( mousePosition )  { 
@@ -119,13 +123,16 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
119123        } 
120124        this . lastOutSideFocusNode  =  null ; 
121125      } 
126+       // if (!props.visible) { 
127+       //   this.switchScrollingEffect(); 
128+       // } 
122129    } 
123130  } 
124131
125132  componentWillUnmount ( )  { 
126133    const  {  visible,  getOpenCount }  =  this . props ; 
127134    if  ( ( visible  ||  this . inTransition )  &&  ! getOpenCount ( ) )  { 
128-       this . removeScrollingEffect ( ) ; 
135+       this . switchScrollingEffect ( ) ; 
129136    } 
130137    clearTimeout ( this . timeoutId ) ; 
131138  } 
@@ -145,7 +152,7 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
145152      this . wrap . style . display  =  'none' ; 
146153    } 
147154    this . inTransition  =  false ; 
148-     this . removeScrollingEffect ( ) ; 
155+     this . switchScrollingEffect ( ) ; 
149156    if  ( afterClose )  { 
150157      afterClose ( ) ; 
151158    } 
@@ -368,26 +375,26 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
368375    return  transitionName ; 
369376  } 
370377
371-   addScrollingEffect  =  ( )  =>  { 
378+   switchScrollingEffect  =  ( )  =>  { 
372379    const  {  getOpenCount }  =  this . props ; 
373380    const  openCount  =  getOpenCount ( ) ; 
374-     if  ( openCount  !==  1 )  { 
375-       return ; 
376-     } 
377-     switchScrollingEffect ( ) ; 
378-     this . cacheOverflow  =  { 
379-       overflowX : document . body . style . overflowX , 
380-       overflowY : document . body . style . overflowY , 
381-     } ; 
382-     document . body . style . overflow  =  'hidden' ; 
383-   } 
384381
385-   removeScrollingEffect  =  ( )  =>  { 
386-     const  {  getOpenCount }  =  this . props ; 
387-     const  openCount  =  getOpenCount ( ) ; 
388-     if  ( ! openCount  &&  this . cacheOverflow )  { 
389-       document . body . style . overflowX  =  this . cacheOverflow . overflowX ; 
390-       document . body . style . overflowY  =  this . cacheOverflow . overflowY ; 
382+     if  ( openCount  ===  1 )  { 
383+       if  ( cacheOverflow . hasOwnProperty ( 'overflowX' ) )  { 
384+         return ; 
385+       } 
386+       cacheOverflow  =  { 
387+         overflowX : document . body . style . overflowX , 
388+         overflowY : document . body . style . overflowY , 
389+       } ; 
390+       document . body . style . overflow  =  'hidden' ; 
391+       switchScrollingEffect ( ) ; 
392+     }  else  if  ( ! openCount )  { 
393+       if  ( cacheOverflow . overflowX  !==  undefined  ||  cacheOverflow . overflowY  !==  undefined )  { 
394+         document . body . style . overflowX  =  cacheOverflow . overflowX ; 
395+         document . body . style . overflowY  =  cacheOverflow . overflowY ; 
396+       } 
397+       cacheOverflow  =  { } ; 
391398      switchScrollingEffect ( true ) ; 
392399    } 
393400  } 
0 commit comments