diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 50d86720831fdd9d683c554e241bed5913c47be1..45c540b3a3c585c9d7f4bf9a38ee65dfa38ad657 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -183,6 +183,15 @@ void LLAvatarList::sortByName()
 	sort();
 }
 
+void LLAvatarList::setDirty(bool val /*= true*/, bool force_refresh /*= false*/)
+{
+	mDirty = val;
+	if(mDirty && force_refresh)
+	{
+		refresh();
+	}
+}
+
 //////////////////////////////////////////////////////////////////////////
 // PROTECTED SECTION
 //////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llavatarlist.h b/indra/newview/llavatarlist.h
index 0e4215e91a37cacb0b3871c390f09850904a2595..00c72f1f9daf9e4e2ba62f5dcf52b5fe3e3b128e 100644
--- a/indra/newview/llavatarlist.h
+++ b/indra/newview/llavatarlist.h
@@ -73,7 +73,7 @@ class LLAvatarList : public LLFlatListView
 	virtual void clear();
 
 	void setNameFilter(const std::string& filter);
-	void setDirty(bool val = true)						{ mDirty = val; }
+	void setDirty(bool val = true, bool force_refresh = false);
 	uuid_vector_t& getIDs() 							{ return mIDs; }
 	bool contains(const LLUUID& id);
 
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index d2a518a06a1765ef4d20b161900148b9d34b0556..93a6a7803a47b5a7443e68902e543c3fa21512c5 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -683,9 +683,15 @@ void LLPanelPeople::updateFriendList()
 			online_friendsp.push_back(buddy_id);
 	}
 
-	mOnlineFriendList->setDirty();
-	mAllFriendList->setDirty();
-
+	/*
+	 * Avatarlists  will be hidden by showFriendsAccordionsIfNeeded(), if they do not have items.
+	 * But avatarlist can be updated only if it is visible @see LLAvatarList::draw();   
+	 * So we need to do force update of lists to avoid inconsistency of data and view of avatarlist. 
+	 */
+	mOnlineFriendList->setDirty(true, !mOnlineFriendList->filterHasMatches());// do force update if list do NOT have items
+	mAllFriendList->setDirty(true, !mAllFriendList->filterHasMatches());
+	//update trash and other buttons according to a selected item
+	updateButtons();
 	showFriendsAccordionsIfNeeded();
 }
 
@@ -1434,9 +1440,8 @@ void LLPanelPeople::onFriendListRefreshComplete(LLUICtrl*ctrl, const LLSD& param
 	{
 		showAccordion("tab_all", param.asInteger());
 	}
+	updateButtons();
 
-	LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("friends_accordion");
-	accordion->arrange();
 }
 
 void LLPanelPeople::setAccordionCollapsedByUser(LLUICtrl* acc_tab, bool collapsed)
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index f1ec489a206d5867586f5b85fd2fa4b6bb1ec4a1..30f2d2c41b49a75f2cd9114428c48d62197e4936 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -695,22 +695,15 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 	{
 		S32 local_x, local_y;
 		top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
-		if (down)
+		if (top_ctrl->pointInView(local_x, local_y))
 		{
-			if (top_ctrl->pointInView(local_x, local_y))
-			{
-				return top_ctrl->handleAnyMouseClick(local_x, local_y, mask, clicktype, down)	;
-			}
-			else
-			{
-				gFocusMgr.setTopCtrl(NULL);
-			}
+			return top_ctrl->handleAnyMouseClick(local_x, local_y, mask, clicktype, down)	;
 		}
 		else
 		{
-			if (top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask))
+			if (down)
 			{
-				return TRUE;
+				gFocusMgr.setTopCtrl(NULL);
 			}
 		}
 	}