From e5c79cd193f778e9036d938ba71c59d6e0cf3dc9 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Thu, 30 Jul 2015 10:54:41 -0400
Subject: makes the LHS dropdown close when clicking on the LHS header

---
 web/react/components/sidebar_header.jsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'web/react/components/sidebar_header.jsx')

diff --git a/web/react/components/sidebar_header.jsx b/web/react/components/sidebar_header.jsx
index 0156dc01a..559f2ef91 100644
--- a/web/react/components/sidebar_header.jsx
+++ b/web/react/components/sidebar_header.jsx
@@ -17,8 +17,15 @@ var NavbarDropdown = React.createClass({
         e.preventDefault();
         client.logout();
     },
+    blockToggle: false,
     componentDidMount: function() {
         UserStore.addTeamsChangeListener(this._onChange);
+
+        var self = this;
+        $(this.refs.dropdown.getDOMNode()).on('hide.bs.dropdown', function(e) {
+            self.blockToggle = true;
+            setTimeout(function(){self.blockToggle = false;}, 100);
+        });
     },
     componentWillUnmount: function() {
         UserStore.removeTeamsChangeListener(this._onChange);
@@ -75,7 +82,7 @@ var NavbarDropdown = React.createClass({
 
         return (
             <ul className="nav navbar-nav navbar-right">
-                <li className="dropdown">
+                <li ref="dropdown" className="dropdown">
                     <a href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                         <span className="dropdown__icon" dangerouslySetInnerHTML={{__html: Constants.MENU_ICON }} />
                     </a>
@@ -108,7 +115,11 @@ module.exports = React.createClass({
     },
 
     toggleDropdown: function(e) {
-        $('.team__header').find('.dropdown-toggle').trigger('click');
+        if (this.refs.dropdown.blockToggle) {
+            this.refs.dropdown.blockToggle = false;
+            return;
+        }
+        $('.team__header').find('.dropdown-toggle').dropdown('toggle');
     },
 
     render: function() {
@@ -131,7 +142,7 @@ module.exports = React.createClass({
                         <div className="team__name">{ this.props.teamDisplayName }</div>
                     </div>
                 </a>
-                <NavbarDropdown teamType={this.props.teamType} />
+                <NavbarDropdown ref="dropdown" teamType={this.props.teamType} />
             </div>
         );
     }
-- 
cgit v1.2.3-1-g7c22

