diff --git a/client/components/Nav.jsx b/client/components/Nav.jsx
index 26aeccd0..e1203f62 100644
--- a/client/components/Nav.jsx
+++ b/client/components/Nav.jsx
@@ -28,14 +28,16 @@ class Nav extends React.PureComponent {
this.clearHideTimeout = this.clearHideTimeout.bind(this);
this.handleClick = this.handleClick.bind(this);
this.handleClickOutside = this.handleClickOutside.bind(this);
+ this.closeDropDown = this.closeDropDown.bind(this);
}
- componentWillMount() {
+ componentDidMount() {
document.addEventListener('mousedown', this.handleClick, false);
+ document.addEventListener('keydown', this.closeDropDown, false);
}
-
componentWillUnmount() {
document.removeEventListener('mousedown', this.handleClick, false);
+ document.removeEventListener('keydown', this.closeDropDown, false);
}
setDropdown(dropdown) {
@@ -44,8 +46,17 @@ class Nav extends React.PureComponent {
});
}
+ closeDropDown(e) {
+ if (e.keyCode === 27) {
+ this.setDropdown('none');
+ }
+ }
+
handleClick(e) {
- if (this.node.contains(e.target)) {
+ if (!this.node) {
+ return;
+ }
+ if (this.node && this.node.contains(e.target)) {
return;
}
@@ -124,18 +135,16 @@ class Nav extends React.PureComponent {
onClick={this.toggleDropdown.bind(this, 'file')}
onBlur={this.handleBlur}
onFocus={this.clearHideTimeout}
+ onMouseOver={() => {
+ if (this.state.dropdownOpen !== 'none') {
+ this.setDropdown('file');
+ }
+ }}
>
File