react-tray
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -88,2 +88,18 @@ 'use strict'; | ||
}); | ||
it('should close on blur by default', function () { | ||
renderTray({ isOpen: true, onBlur: function onBlur() {}, closeTimeoutMS: 0 }); | ||
_reactAddonsTestUtils2['default'].Simulate.keyDown(document.querySelector('.ReactTray__Content'), { key: 'Tab' }); | ||
setTimeout(function () { | ||
(0, _assert.equal)(document.querySelectorAll('.ReactTray__Content').length, 0); | ||
}, 0); | ||
}); | ||
it('should not close on blur', function () { | ||
renderTray({ isOpen: true, onBlur: function onBlur() {}, closeTimeoutMS: 0, closeOnBlur: false }); | ||
_reactAddonsTestUtils2['default'].Simulate.keyDown(document.querySelector('.ReactTray__Content'), { key: 'Tab' }); | ||
setTimeout(function () { | ||
(0, _assert.equal)(document.querySelectorAll('.ReactTray__Content').length, 1); | ||
}, 0); | ||
}); | ||
}); |
@@ -29,3 +29,4 @@ 'use strict'; | ||
onBlur: _react2['default'].PropTypes.func, | ||
closeTimeoutMS: _react2['default'].PropTypes.number | ||
closeTimeoutMS: _react2['default'].PropTypes.number, | ||
closeOnBlur: _react2['default'].PropTypes.bool | ||
}, | ||
@@ -36,3 +37,4 @@ | ||
isOpen: false, | ||
closeTimeoutMS: 0 | ||
closeTimeoutMS: 0, | ||
closeOnBlur: true | ||
}; | ||
@@ -39,0 +41,0 @@ }, |
@@ -75,2 +75,3 @@ 'use strict'; | ||
onBlur: _react.PropTypes.func, | ||
closeOnBlur: _react.PropTypes.bool, | ||
closeTimeoutMS: _react.PropTypes.number, | ||
@@ -130,4 +131,4 @@ children: _react.PropTypes.any | ||
// Treat tabbing away from content as blur/close | ||
if (e.keyCode === 9 && (0, _helpersIsLeavingNode2['default'])(this.refs.content, e)) { | ||
// Treat tabbing away from content as blur/close if closeOnBlur | ||
if (e.keyCode === 9 && this.props.closeOnBlur && (0, _helpersIsLeavingNode2['default'])(this.refs.content, e)) { | ||
e.preventDefault(); | ||
@@ -134,0 +135,0 @@ this.props.onBlur(); |
{ | ||
"name": "react-tray", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "An accessible tray component useful for navigation menus", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14989
375