diff --git a/indra/newview/llsidetray.cpp b/indra/newview/llsidetray.cpp
index 9893370dcf586fb15379bd6ed6ccbc3db3c22d57..086e35dfdc473ad8b82c2058ff80427121fb0224 100644
--- a/indra/newview/llsidetray.cpp
+++ b/indra/newview/llsidetray.cpp
@@ -176,6 +176,7 @@ BOOL LLSideTrayTab::postBuild()
 	
 	title_panel->getChild<LLTextBox>(TAB_PANEL_CAPTION_TITLE_BOX)->setValue(mTabTitle);
 
+	getChild<LLButton>("undock")->setCommitCallback(boost::bind(&LLSideTrayTab::toggleTabDocked, this));
 	getChild<LLButton>("dock")->setCommitCallback(boost::bind(&LLSideTrayTab::toggleTabDocked, this));
 
 	return true;
@@ -221,7 +222,14 @@ void LLSideTrayTab::toggleTabDocked()
 
 	LLSideTray* side_tray = LLSideTray::getInstance();
 
-	if (LLFloater::isShown(floater_tab))
+	bool is_tab_undocked = LLFloater::isShown(floater_tab);
+
+	// Hide the "Tear Off" button when a tab gets undocked
+	// and show "Dock" button instead.
+	getChild<LLButton>("undock")->setVisible(!is_tab_undocked);
+	getChild<LLButton>("dock")->setVisible(is_tab_undocked);
+
+	if (is_tab_undocked)
 	{
 		// Remove the tab from Side Tray's tabs list.
 		// We have to do it despite removing the tab from Side Tray's child view tree
diff --git a/indra/newview/skins/default/xui/en/panel_side_tray_tab_caption.xml b/indra/newview/skins/default/xui/en/panel_side_tray_tab_caption.xml
index 60c2e0830c0390dcfb986cf86063d52ec2083195..349b625cef51eb002a4e5b4b83e22ade98d1e77a 100644
--- a/indra/newview/skins/default/xui/en/panel_side_tray_tab_caption.xml
+++ b/indra/newview/skins/default/xui/en/panel_side_tray_tab_caption.xml
@@ -22,6 +22,18 @@
      <button
      follows="right|top"
      height="16"
+     image_selected="tearoffbox.tga"
+     image_unselected="tearoffbox.tga"
+     image_disabled="tearoff_pressed.tga"
+     layout="topleft"
+     name="undock"
+     top="10"
+     right="-28"
+     width="16"
+     tool_tip="Undock" />
+     <button
+     follows="right|top"
+     height="16"
      image_selected="Icon_Dock_Press"
      image_unselected="Icon_Dock_Foreground"
      image_disabled="Icon_Dock_Press"
@@ -30,7 +42,8 @@
      top="10"
      right="-28"
      width="16"
-     tool_tip="Dock/Undock tab" />
+     tool_tip="Dock"
+     visible="false" />
      <button
      follows="right|top"
      height="16"