66 else if ( typeof exports === 'object' )
77 exports [ "ReactModal" ] = factory ( require ( "react" ) , require ( "react-dom" ) ) ;
88 else
9- root [ "ReactModal" ] = factory ( root [ "react " ] , root [ "react-dom " ] ) ;
9+ root [ "ReactModal" ] = factory ( root [ "React " ] , root [ "ReactDOM " ] ) ;
1010} ) ( this , function ( __WEBPACK_EXTERNAL_MODULE_2__ , __WEBPACK_EXTERNAL_MODULE_3__ ) {
1111return /******/ ( function ( modules ) { // webpackBootstrap
1212/******/ // The module cache
@@ -94,17 +94,20 @@ return /******/ (function(modules) { // webpackBootstrap
9494 content : React . PropTypes . object ,
9595 overlay : React . PropTypes . object
9696 } ) ,
97+ portalClassName : React . PropTypes . string ,
9798 appElement : React . PropTypes . instanceOf ( SafeHTMLElement ) ,
9899 onAfterOpen : React . PropTypes . func ,
99100 onRequestClose : React . PropTypes . func ,
100101 closeTimeoutMS : React . PropTypes . number ,
101102 ariaHideApp : React . PropTypes . bool ,
102- shouldCloseOnOverlayClick : React . PropTypes . bool
103+ shouldCloseOnOverlayClick : React . PropTypes . bool ,
104+ role : React . PropTypes . string
103105 } ,
104106
105107 getDefaultProps : function getDefaultProps ( ) {
106108 return {
107109 isOpen : false ,
110+ portalClassName : 'ReactModalPortal' ,
108111 ariaHideApp : true ,
109112 closeTimeoutMS : 0 ,
110113 shouldCloseOnOverlayClick : true
@@ -113,7 +116,7 @@ return /******/ (function(modules) { // webpackBootstrap
113116
114117 componentDidMount : function componentDidMount ( ) {
115118 this . node = document . createElement ( 'div' ) ;
116- this . node . className = 'ReactModalPortal' ;
119+ this . node . className = this . props . portalClassName ;
117120 document . body . appendChild ( this . node ) ;
118121 this . renderPortal ( this . props ) ;
119122 } ,
@@ -260,6 +263,7 @@ return /******/ (function(modules) { // webpackBootstrap
260263 var ModalPortal = module . exports = React . createClass ( {
261264
262265 displayName : 'ModalPortal' ,
266+ shouldClose : null ,
263267
264268 getDefaultProps : function getDefaultProps ( ) {
265269 return {
@@ -333,7 +337,10 @@ return /******/ (function(modules) { // webpackBootstrap
333337 } ,
334338
335339 focusContent : function focusContent ( ) {
336- this . refs . content . focus ( ) ;
340+ // Don't steal focus from inner elements
341+ if ( ! this . contentHasFocus ( ) ) {
342+ this . refs . content . focus ( ) ;
343+ }
337344 } ,
338345
339346 closeWithTimeout : function closeWithTimeout ( ) {
@@ -363,17 +370,25 @@ return /******/ (function(modules) { // webpackBootstrap
363370 }
364371 } ,
365372
366- handleOverlayClick : function handleOverlayClick ( event ) {
367- var node = event . target ;
368-
369- while ( node ) {
370- if ( node === this . refs . content ) return ;
371- node = node . parentNode ;
373+ handleOverlayMouseDown : function handleOverlayMouseDown ( event ) {
374+ if ( this . shouldClose === null ) {
375+ this . shouldClose = true ;
372376 }
377+ } ,
373378
374- if ( this . props . shouldCloseOnOverlayClick ) {
379+ handleOverlayMouseUp : function handleOverlayMouseUp ( event ) {
380+ if ( this . shouldClose && this . props . shouldCloseOnOverlayClick ) {
375381 if ( this . ownerHandlesClose ( ) ) this . requestClose ( event ) ; else this . focusContent ( ) ;
376382 }
383+ this . shouldClose = null ;
384+ } ,
385+
386+ handleContentMouseDown : function handleContentMouseDown ( event ) {
387+ this . shouldClose = false ;
388+ } ,
389+
390+ handleContentMouseUp : function handleContentMouseUp ( event ) {
391+ this . shouldClose = false ;
377392 } ,
378393
379394 requestClose : function requestClose ( event ) {
@@ -388,6 +403,10 @@ return /******/ (function(modules) { // webpackBootstrap
388403 return ! this . props . isOpen && ! this . state . beforeClose ;
389404 } ,
390405
406+ contentHasFocus : function contentHasFocus ( ) {
407+ return document . activeElement === this . refs . content || this . refs . content . contains ( document . activeElement ) ;
408+ } ,
409+
391410 buildClassName : function buildClassName ( which , additional ) {
392411 var className = CLASS_NAMES [ which ] . base ;
393412 if ( this . state . afterOpen ) className += ' ' + CLASS_NAMES [ which ] . afterOpen ;
@@ -403,13 +422,17 @@ return /******/ (function(modules) { // webpackBootstrap
403422 ref : "overlay" ,
404423 className : this . buildClassName ( 'overlay' , this . props . overlayClassName ) ,
405424 style : Assign ( { } , overlayStyles , this . props . style . overlay || { } ) ,
406- onClick : this . handleOverlayClick
425+ onMouseDown : this . handleOverlayMouseDown ,
426+ onMouseUp : this . handleOverlayMouseUp
407427 } , div ( {
408428 ref : "content" ,
409429 style : Assign ( { } , contentStyles , this . props . style . content || { } ) ,
410430 className : this . buildClassName ( 'content' , this . props . className ) ,
411431 tabIndex : "-1" ,
412- onKeyDown : this . handleKeyDown
432+ onKeyDown : this . handleKeyDown ,
433+ onMouseDown : this . handleContentMouseDown ,
434+ onMouseUp : this . handleContentMouseUp ,
435+ role : "dialog"
413436 } , this . props . children ) ) ;
414437 }
415438 } ) ;
@@ -437,8 +460,8 @@ return /******/ (function(modules) { // webpackBootstrap
437460 }
438461 // need to see how jQuery shims document.on('focusin') so we don't need the
439462 // setTimeout, firefox doesn't support focusin, if it did, we could focus
440- // the element outside of a setTimeout. Side-effect of this implementation
441- // is that the document.body gets focus, and then we focus our element right
463+ // the element outside of a setTimeout. Side-effect of this implementation
464+ // is that the document.body gets focus, and then we focus our element right
442465 // after, seems fine.
443466 setTimeout ( function ( ) {
444467 if ( modalElement . contains ( document . activeElement ) ) return ;
@@ -1107,12 +1130,12 @@ return /******/ (function(modules) { // webpackBootstrap
11071130/***/ function ( module , exports ) {
11081131
11091132 /**
1110- * lodash 3.0.8 (Custom Build) <https://lodash.com/>
1133+ * lodash (Custom Build) <https://lodash.com/>
11111134 * Build: `lodash modularize exports="npm" -o ./`
1112- * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
1135+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
1136+ * Released under MIT license <https://lodash.com/license>
11131137 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1114- * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1115- * Available under MIT license <https://lodash.com/license>
1138+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11161139 */
11171140
11181141 /** Used as references for various `Number` constants. */
@@ -1130,47 +1153,25 @@ return /******/ (function(modules) { // webpackBootstrap
11301153 var hasOwnProperty = objectProto . hasOwnProperty ;
11311154
11321155 /**
1133- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
1156+ * Used to resolve the
1157+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11341158 * of values.
11351159 */
11361160 var objectToString = objectProto . toString ;
11371161
11381162 /** Built-in value references. */
11391163 var propertyIsEnumerable = objectProto . propertyIsEnumerable ;
11401164
1141- /**
1142- * The base implementation of `_.property` without support for deep paths.
1143- *
1144- * @private
1145- * @param {string } key The key of the property to get.
1146- * @returns {Function } Returns the new function.
1147- */
1148- function baseProperty ( key ) {
1149- return function ( object ) {
1150- return object == null ? undefined : object [ key ] ;
1151- } ;
1152- }
1153-
1154- /**
1155- * Gets the "length" property value of `object`.
1156- *
1157- * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
1158- * that affects Safari on at least iOS 8.1-8.3 ARM64.
1159- *
1160- * @private
1161- * @param {Object } object The object to query.
1162- * @returns {* } Returns the "length" value.
1163- */
1164- var getLength = baseProperty ( 'length' ) ;
1165-
11661165 /**
11671166 * Checks if `value` is likely an `arguments` object.
11681167 *
11691168 * @static
11701169 * @memberOf _
1170+ * @since 0.1.0
11711171 * @category Lang
11721172 * @param {* } value The value to check.
1173- * @returns {boolean } Returns `true` if `value` is correctly classified, else `false`.
1173+ * @returns {boolean } Returns `true` if `value` is an `arguments` object,
1174+ * else `false`.
11741175 * @example
11751176 *
11761177 * _.isArguments(function() { return arguments; }());
@@ -1180,7 +1181,7 @@ return /******/ (function(modules) { // webpackBootstrap
11801181 * // => false
11811182 */
11821183 function isArguments ( value ) {
1183- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
1184+ // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
11841185 return isArrayLikeObject ( value ) && hasOwnProperty . call ( value , 'callee' ) &&
11851186 ( ! propertyIsEnumerable . call ( value , 'callee' ) || objectToString . call ( value ) == argsTag ) ;
11861187 }
@@ -1192,6 +1193,7 @@ return /******/ (function(modules) { // webpackBootstrap
11921193 *
11931194 * @static
11941195 * @memberOf _
1196+ * @since 4.0.0
11951197 * @category Lang
11961198 * @param {* } value The value to check.
11971199 * @returns {boolean } Returns `true` if `value` is array-like, else `false`.
@@ -1210,7 +1212,7 @@ return /******/ (function(modules) { // webpackBootstrap
12101212 * // => false
12111213 */
12121214 function isArrayLike ( value ) {
1213- return value != null && isLength ( getLength ( value ) ) && ! isFunction ( value ) ;
1215+ return value != null && isLength ( value . length ) && ! isFunction ( value ) ;
12141216 }
12151217
12161218 /**
@@ -1219,9 +1221,11 @@ return /******/ (function(modules) { // webpackBootstrap
12191221 *
12201222 * @static
12211223 * @memberOf _
1224+ * @since 4.0.0
12221225 * @category Lang
12231226 * @param {* } value The value to check.
1224- * @returns {boolean } Returns `true` if `value` is an array-like object, else `false`.
1227+ * @returns {boolean } Returns `true` if `value` is an array-like object,
1228+ * else `false`.
12251229 * @example
12261230 *
12271231 * _.isArrayLikeObject([1, 2, 3]);
@@ -1245,9 +1249,10 @@ return /******/ (function(modules) { // webpackBootstrap
12451249 *
12461250 * @static
12471251 * @memberOf _
1252+ * @since 0.1.0
12481253 * @category Lang
12491254 * @param {* } value The value to check.
1250- * @returns {boolean } Returns `true` if `value` is correctly classified , else `false`.
1255+ * @returns {boolean } Returns `true` if `value` is a function , else `false`.
12511256 * @example
12521257 *
12531258 * _.isFunction(_);
@@ -1258,19 +1263,20 @@ return /******/ (function(modules) { // webpackBootstrap
12581263 */
12591264 function isFunction ( value ) {
12601265 // The use of `Object#toString` avoids issues with the `typeof` operator
1261- // in Safari 8 which returns 'object' for typed array and weak map constructors,
1262- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
1266+ // in Safari 8-9 which returns 'object' for typed array and other constructors.
12631267 var tag = isObject ( value ) ? objectToString . call ( value ) : '' ;
12641268 return tag == funcTag || tag == genTag ;
12651269 }
12661270
12671271 /**
12681272 * Checks if `value` is a valid array-like length.
12691273 *
1270- * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
1274+ * **Note:** This method is loosely based on
1275+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12711276 *
12721277 * @static
12731278 * @memberOf _
1279+ * @since 4.0.0
12741280 * @category Lang
12751281 * @param {* } value The value to check.
12761282 * @returns {boolean } Returns `true` if `value` is a valid length, else `false`.
@@ -1294,11 +1300,13 @@ return /******/ (function(modules) { // webpackBootstrap
12941300 }
12951301
12961302 /**
1297- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
1298- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1303+ * Checks if `value` is the
1304+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1305+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
12991306 *
13001307 * @static
13011308 * @memberOf _
1309+ * @since 0.1.0
13021310 * @category Lang
13031311 * @param {* } value The value to check.
13041312 * @returns {boolean } Returns `true` if `value` is an object, else `false`.
@@ -1327,6 +1335,7 @@ return /******/ (function(modules) { // webpackBootstrap
13271335 *
13281336 * @static
13291337 * @memberOf _
1338+ * @since 4.0.0
13301339 * @category Lang
13311340 * @param {* } value The value to check.
13321341 * @returns {boolean } Returns `true` if `value` is object-like, else `false`.
0 commit comments