File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -62,25 +62,27 @@ class ClickOutside extends React.Component {
6262 document . removeEventListener ( 'mousedown' , this . handleDocumentClick ) ;
6363 }
6464
65+ setClickedInsideStatus = ( status ) => {
66+ this . isClickedInside = status || false ;
67+ }
68+
6569 handleDocumentClick = ( e ) => {
6670 if ( this . isClickedInside ) {
67- this . isClickedInside = false ;
71+ this . setClickedInsideStatus ( false ) ;
6872 return ;
6973 }
7074
7175 this . props . onClickOutside ( e ) ;
7276 } ;
7377
7478 handleMouseDown = ( ) => {
75- this . isClickedInside = true ;
79+ this . setClickedInsideStatus ( true ) ;
7680 } ;
7781
7882 render ( ) {
79- return React . cloneElement (
80- React . Children . only ( this . props . children ) , {
81- onMouseDownCapture : this . handleMouseDown
82- }
83- ) ;
83+ return React . cloneElement ( React . Children . only ( this . props . children ) , {
84+ onMouseDownCapture : this . handleMouseDown
85+ } ) ;
8486 }
8587}
8688
Original file line number Diff line number Diff line change @@ -97,6 +97,10 @@ class SelectOptionGroup extends Component {
9797 if ( isInModal ) {
9898 e . stopPropagation ( ) ;
9999 e . nativeEvent . stopImmediatePropagation ( ) ;
100+
101+ // ClickOutside set isClickedInside to true via mouse down capture first
102+ // Set isClickedInside to false after mouse down
103+ this . clickOutsideRef && this . clickOutsideRef . setClickedInsideStatus ( false ) ;
100104 }
101105 } ;
102106
@@ -177,7 +181,7 @@ class SelectOptionGroup extends Component {
177181 } ;
178182 }
179183 return (
180- < ClickOutside onClickOutside = { this . props . onClickOutside } >
184+ < ClickOutside ref = { ref => this . clickOutsideRef = ref } onClickOutside = { this . props . onClickOutside } >
181185 < div
182186 className = { classnames ( 'option-group' , className ? 'option-group-' + className : '' , {
183187 'pt-0' : isShowSelected ,
You can’t perform that action at this time.
0 commit comments