diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp
index d57d414ff8e34e30a01c1b955151070022d40d14..a70e23cfd39fc395f7d1de1a80140e77ac00123e 100644
--- a/indra/newview/llsidetray.cpp
+++ b/indra/newview/llsidetray.cpp
@@ -65,6 +65,7 @@ static const std::string TAB_PANEL_CAPTION_TITLE_BOX = "sidetray_tab_title";
 
 LLSideTray* LLSideTray::sInstance = 0;
 
+// static
 LLSideTray* LLSideTray::getInstance()
 {
 	if (!sInstance)
@@ -76,6 +77,7 @@ LLSideTray* LLSideTray::getInstance()
 	return sInstance;
 }
 
+// static
 bool	LLSideTray::instanceCreated	()
 {
 	return sInstance!=0;
@@ -369,6 +371,11 @@ LLSideTrayTab* LLSideTray::getTab(const std::string& name)
 	return getChild<LLSideTrayTab>(name,false);
 }
 
+bool LLSideTray::hasTabs()
+{
+	// The open/close tab doesn't count.
+	return mTabs.size() > 1;
+}
 
 void LLSideTray::toggleTabButton(LLSideTrayTab* tab)
 {
@@ -406,10 +413,6 @@ bool LLSideTray::selectTabByName	(const std::string& name)
 	if (mActiveTab)
 	{
 		toggleTabButton(mActiveTab);
-		if(mActiveTab)
-		{
-			mActiveTab->setVisible(false);
-		}
 	}
 
 	//select new tab
@@ -420,8 +423,6 @@ bool LLSideTray::selectTabByName	(const std::string& name)
 		toggleTabButton(mActiveTab);
 		LLSD key;//empty
 		mActiveTab->onOpen(key);
-
-		mActiveTab->setVisible(true);
 	}
 
 	//arrange();
@@ -431,7 +432,9 @@ bool LLSideTray::selectTabByName	(const std::string& name)
 	for ( child_it = mTabs.begin(); child_it != mTabs.end(); ++child_it)
 	{
 		LLSideTrayTab* sidebar_tab = *child_it;
-		sidebar_tab->setVisible(sidebar_tab  == mActiveTab);
+		// When the last tab gets detached, for a short moment the "Toggle Sidebar" pseudo-tab
+		// is shown. So, to avoid the flicker we make sure it never gets visible.
+		sidebar_tab->setVisible(sidebar_tab == mActiveTab && (*child_it)->getName() != "sidebar_openclose");
 	}
 	return true;
 }
@@ -716,6 +719,9 @@ void LLSideTray::arrange()
 		LLSideTrayTab* sidebar_tab = *child_it;
 		sidebar_tab->setShape(getLocalRect());
 	}
+
+	// The tab buttons should be shown only if there is at least one non-detached tab.
+	mButtonsPanel->setVisible(hasTabs());
 }
 
 void LLSideTray::collapseSideBar()
diff --git a/indra/newview/llsidetray.h b/indra/newview/llsidetray.h
index 081f382478928a6b7666d64d9c45478b3abd13a3..382a849814e73cb39f2dac096988a08921c790bb 100644
--- a/indra/newview/llsidetray.h
+++ b/indra/newview/llsidetray.h
@@ -163,6 +163,7 @@ public:
 
 protected:
 	LLSideTrayTab* getTab		(const std::string& name);
+	bool		hasTabs			();
 
 	void		createButtons	();
 	LLButton*	createButton	(const std::string& name,const std::string& image,const std::string& tooltip,