From 9b0763516352f60e8532d0fa177b76fd96ffd582 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Wed, 29 Apr 2015 20:29:56 +0300
Subject: [PATCH] MAINT-839 FIXED [PUBLIC]Clicking a menu a second time does
 not close it.

---
 indra/llui/llmenugl.cpp | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 7cdbcb06218..43ceb0e4c6e 100755
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -1043,7 +1043,7 @@ void LLMenuItemBranchGL::onCommit( void )
 
 	// keyboard navigation automatically propagates highlight to sub-menu
 	// to facilitate fast menu control via jump keys
-	if (LLMenuGL::getKeyboardMode() && getBranch()&& !getBranch()->getHighlightedItem())
+	if (LLMenuGL::getKeyboardMode() && getBranch() && !getBranch()->getHighlightedItem())
 	{
 		getBranch()->highlightNextItem(NULL);
 	}
@@ -1456,7 +1456,24 @@ BOOL LLMenuItemBranchDownGL::handleMouseDown( S32 x, S32 y, MASK mask )
 {
 	// switch to mouse control mode
 	LLMenuGL::setKeyboardMode(FALSE);
-	onCommit();
+
+	if (getVisible() && getHighlight() && getBranch())
+	{
+		// already open - hide menu
+		LLMenuGL::setKeyboardMode(FALSE);
+		for (child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+		{
+			LLView* viewp = *child_it;
+			if (dynamic_cast<LLMenuGL*>(viewp) != NULL && viewp->getVisible())
+			{
+				viewp->setVisible(FALSE);
+			}
+		}
+	}
+	else
+	{
+		onCommit();
+	}
 	make_ui_sound("UISndClick");
 	return TRUE;
 }
-- 
GitLab