diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 04f6b11b7c7020587f6e6e013c94b496ebba556f..6f341bc0cdded3a97533ee1fe55514353c2f7d4a 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -2486,7 +2486,7 @@ void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus, BOOL restore
 
 	if (mFrontChild == child)
 	{
-		if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
+		if (give_focus && child->canFocusStealFrontmost() && !gFocusMgr.childHasKeyboardFocus(child))
 		{
 			child->setFocus(TRUE);
 		}
@@ -3042,24 +3042,29 @@ void LLFloaterView::syncFloaterTabOrder()
                 if (mFrontChild != floaterp)
                 {
                     // Grab a list of the top floaters that want to stay on top of the focused floater
-					std::list<LLView*> listTop;
+					std::list<LLFloater*> listTop;
 					if (mFrontChild && !mFrontChild->canFocusStealFrontmost())
                     {
-                        for (LLView* childfloaterp : *getChildList())
+                        for (LLView* childp : *getChildList())
                         {
-                            if (static_cast<LLFloater*>(childfloaterp)->canFocusStealFrontmost())
+							LLFloater* child_floaterp = static_cast<LLFloater*>(childp);
+                            if (child_floaterp->canFocusStealFrontmost())
                                 break;
-							listTop.push_back(childfloaterp);
+							listTop.push_back(child_floaterp);
                         }
                     }
 
                     bringToFront(floaterp, FALSE);
 
                     // Restore top floaters
-                    for (LLView* childp :listTop)
-                    {
-                        sendChildToFront(childp);
-                    }
+					if (!listTop.empty())
+					{
+						for (LLView* childp : listTop)
+						{
+							sendChildToFront(childp);
+						}
+						mFrontChild = listTop.back();
+					}
                 }
 
 				break;
diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp
index f890a14e8eddb261c5618ac8b6e6cf512c617af2..8b89e3aa140f9771dec17e83b7c4a1df71385107 100644
--- a/indra/newview/llpanelemojicomplete.cpp
+++ b/indra/newview/llpanelemojicomplete.cpp
@@ -120,9 +120,6 @@ BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent
 			case KEY_RETURN:
 				if (!mEmojis.empty())
 				{
-					LLWString wstr;
-					wstr.push_back(mEmojis.at(mCurSelected));
-					setValue(wstring_to_utf8str(wstr));
 					onCommit();
 					handled = true;
 				}
@@ -137,6 +134,33 @@ BOOL LLPanelEmojiComplete::handleKey(KEY key, MASK mask, BOOL called_from_parent
 	return LLUICtrl::handleKey(key, mask, called_from_parent);
 }
 
+BOOL LLPanelEmojiComplete::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+	mCurSelected = posToIndex(x, y);
+	mLastHover = LLVector2(x, y);
+
+	return TRUE;
+}
+
+BOOL LLPanelEmojiComplete::handleMouseUp(S32 x, S32 y, MASK mask)
+{
+	mCurSelected = posToIndex(x, y);
+	onCommit();
+
+	return TRUE;
+}
+
+void LLPanelEmojiComplete::onCommit()
+{
+	if (npos != mCurSelected)
+	{
+		LLWString wstr;
+		wstr.push_back(mEmojis.at(mCurSelected));
+		setValue(wstring_to_utf8str(wstr));
+		LLUICtrl::onCommit();
+	}
+}
+
 void LLPanelEmojiComplete::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
 	LLUICtrl::reshape(width, height, called_from_parent);
diff --git a/indra/newview/llpanelemojicomplete.h b/indra/newview/llpanelemojicomplete.h
index 138cc465baf128567dcaf622c9e37075952634b5..2116b350bec115904325cddd1bcc0543d0673170 100644
--- a/indra/newview/llpanelemojicomplete.h
+++ b/indra/newview/llpanelemojicomplete.h
@@ -56,6 +56,9 @@ class LLPanelEmojiComplete : public LLUICtrl
 	void draw() override;
 	BOOL handleHover(S32 x, S32 y, MASK mask) override;
 	BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent) override;
+	BOOL handleMouseDown(S32 x, S32 y, MASK mask) override;
+	BOOL handleMouseUp(S32 x, S32 y, MASK mask) override;
+	void onCommit() override;
 	void reshape(S32 width, S32 height, BOOL called_from_parent) override;
 
 public: