Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-tray

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tray - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

16

lib/components/__tests__/Tray-test.js

@@ -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);
});
});

6

lib/components/Tray.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc