@@ -4,6 +4,7 @@ import * as DOMHelpers from './dom-helpers';
4
4
import uid from './uid' ;
5
5
6
6
const handlersMap = { } ;
7
+ const enabledInstances = { } ;
7
8
8
9
const touchEvents = [ 'touchstart' , 'touchmove' ] ;
9
10
export const IGNORE_CLASS_NAME = 'ignore-react-onclickoutside' ;
@@ -107,7 +108,8 @@ export default function onClickOutsideHOC(WrappedComponent, config) {
107
108
* for clicks and touches outside of this element.
108
109
*/
109
110
enableOnClickOutside = ( ) => {
110
- if ( typeof document === 'undefined' ) return ;
111
+ if ( typeof document === 'undefined' || enabledInstances [ this . _uid ] ) return ;
112
+ enabledInstances [ this . _uid ] = true ;
111
113
112
114
let events = this . props . eventTypes ;
113
115
if ( ! events . forEach ) {
@@ -154,7 +156,9 @@ export default function onClickOutsideHOC(WrappedComponent, config) {
154
156
* for clicks and touches outside of this element.
155
157
*/
156
158
disableOnClickOutside = ( ) => {
159
+ delete enabledInstances [ this . _uid ] ;
157
160
const fn = handlersMap [ this . _uid ] ;
161
+
158
162
if ( fn && typeof document !== 'undefined' ) {
159
163
let events = this . props . eventTypes ;
160
164
if ( ! events . forEach ) {
@@ -171,10 +175,12 @@ export default function onClickOutsideHOC(WrappedComponent, config) {
171
175
* Pass-through render
172
176
*/
173
177
render ( ) {
174
- var props = Object . keys ( this . props ) . filter ( prop => prop !== 'excludeScrollbar' ) . reduce ( ( props , prop ) => {
175
- props [ prop ] = this . props [ prop ] ;
176
- return props ;
177
- } , { } ) ;
178
+ var props = Object . keys ( this . props )
179
+ . filter ( prop => prop !== 'excludeScrollbar' )
180
+ . reduce ( ( props , prop ) => {
181
+ props [ prop ] = this . props [ prop ] ;
182
+ return props ;
183
+ } , { } ) ;
178
184
179
185
if ( WrappedComponent . prototype . isReactComponent ) {
180
186
props . ref = this . getRef ;
0 commit comments