From 9433d188fc6d6135991372aafb474db4b5c149fe Mon Sep 17 00:00:00 2001 From: siddhant <30566406+siddhant1@users.noreply.github.com> Date: Wed, 27 Mar 2019 22:20:55 +0530 Subject: [PATCH] Added autoOpen items on hover (#900) * AutoOpen Header * removed nav heading * Fixed #908 * Fixed Styles * Fixed styles * Refactor editor * Issues Fixed * keyup -> keyown --- client/components/Nav.jsx | 79 +++++++++---------- client/styles/components/_nav.scss | 120 ++++++++++++++++++----------- 2 files changed, 115 insertions(+), 84 deletions(-) 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