File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ const DrawerBase = (props: DrawerProps) => {
5050 } ) . start ( ) ;
5151
5252 return (
53- < Modal visible = { isVisible } transparent onRequestClose = { onClose } >
53+ < Modal visible transparent onRequestClose = { onClose } >
5454 < View style = { modalContainerStyle } >
5555 < Animated . View
5656 style = { {
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ class ModalBase extends React.PureComponent<ModalBaseProps> {
1111 public el : HTMLDivElement | null ;
1212 public modalRoot : HTMLBodyElement | null ;
1313 public focusTrap : FocusTrap | null ;
14+ /** Solves the scenario where it is unmounting, we should deactivate focus but not trigger `onRequestClose()` */
15+ public isUnmounting : boolean = false ;
1416 public content : React . RefObject < HTMLDivElement > = React . createRef <
1517 HTMLDivElement
1618 > ( ) ;
@@ -49,6 +51,9 @@ class ModalBase extends React.PureComponent<ModalBaseProps> {
4951 if ( this . modalRoot && this . el ) {
5052 this . modalRoot . removeChild ( this . el ) ;
5153 }
54+
55+ this . isUnmounting = true ;
56+ this . deactivateFocus ( ) ;
5257 }
5358
5459 public freezeBody = ( ) => {
@@ -68,7 +73,7 @@ class ModalBase extends React.PureComponent<ModalBaseProps> {
6873 this . focusTrap = createFocusTrap ( this . content . current , {
6974 initialFocus : this . content . current ,
7075 onDeactivate : ( ) => {
71- if ( onRequestClose && this . props . visible ) {
76+ if ( onRequestClose && this . props . visible && ! this . isUnmounting ) {
7277 onRequestClose ( ) ;
7378 }
7479 } ,
You can’t perform that action at this time.
0 commit comments