diff --git a/indra/llui/llaccordionctrl.h b/indra/llui/llaccordionctrl.h
index 3ad52740855790a03aa1845d84a5f944e6f5e92a..b5fdf796cd73ff07407d9b9797010044f38d202a 100644
--- a/indra/llui/llaccordionctrl.h
+++ b/indra/llui/llaccordionctrl.h
@@ -138,6 +138,8 @@ class LLAccordionCtrl: public LLPanel
 	 */
 	const LLAccordionCtrlTab* getExpandedTab() const;
 
+	const LLAccordionCtrlTab* getSelectedTab() const { return mSelectedTab; }
+
 private:
 	void	initNoTabsWidget(const LLTextBox::Params& tb_params);
 	void	updateNoTabsHelpTextVisibility();
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index 73c850e1fb2a51c51fc2df295544a37607b69c18..927ea19d9802c80f48458a843b0a042952843133 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -326,19 +326,13 @@ void LLOutfitsList::refreshList(const LLUUID& category_id)
 			// 1. Remove outfit category from observer to stop monitoring its changes.
 			mCategoriesObserver->removeCategory(outfit_id);
 
-			// 2. Remove selected lists map entry.
-			mSelectedListsMap.erase(outfit_id);
+			// 2. Remove the outfit from selection.
+			deselectOutfit(outfit_id);
 
-			// 3. Reset currently selected outfit id if it is being removed.
-			if (outfit_id == mSelectedOutfitUUID)
-			{
-				setSelectedOutfitUUID(LLUUID());
-			}
-
-			// 4. Remove category UUID to accordion tab mapping.
+			// 3. Remove category UUID to accordion tab mapping.
 			mOutfitsMap.erase(outfits_iter);
 
-			// 5. Remove outfit tab from accordion.
+			// 4. Remove outfit tab from accordion.
 			mAccordion->removeCollapsibleCtrl(tab);
 		}
 	}
@@ -494,6 +488,27 @@ void LLOutfitsList::setSelectedOutfitUUID(const LLUUID& category_id)
 	mSelectionChangeSignal(mSelectedOutfitUUID = category_id);
 }
 
+void LLOutfitsList::deselectOutfit(const LLUUID& category_id)
+{
+	// Remove selected lists map entry.
+	mSelectedListsMap.erase(category_id);
+
+	// Reset selection if the outfit is selected.
+	if (category_id == mSelectedOutfitUUID)
+	{
+		setSelectedOutfitUUID(LLUUID::null);
+	}
+}
+
+void LLOutfitsList::restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID& category_id)
+{
+	// Try restoring outfit selection after filtering.
+	if (mAccordion->getSelectedTab() == tab)
+	{
+		setSelectedOutfitUUID(category_id);
+	}
+}
+
 void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
 {
 	if (!ctrl || mFilterSubString.empty())
@@ -510,26 +525,7 @@ void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl)
 		LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
 		if (list != ctrl) continue;
 
-		std::string title = tab->getTitle();
-		LLStringUtil::toUpper(title);
-
-		std::string cur_filter = mFilterSubString;
-		LLStringUtil::toUpper(cur_filter);
-
-		if (std::string::npos == title.find(cur_filter))
-		{
-			// hide tab if its title doesn't pass filter
-			// and it has no visible items
-			tab->setVisible(list->size() != 0);
-
-			// remove title highlighting because it might
-			// have been previously highlighted by less restrictive filter
-			tab->setTitle(tab->getTitle());
-		}
-		else
-		{
-			tab->setTitle(tab->getTitle(), cur_filter);
-		}
+		applyFilterToTab(iter->first, tab, mFilterSubString);
 	}
 }
 
@@ -568,26 +564,7 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring)
 
 		if (!new_filter_substring.empty())
 		{
-			std::string title = tab->getTitle();
-			LLStringUtil::toUpper(title);
-
-			std::string cur_filter = new_filter_substring;
-			LLStringUtil::toUpper(cur_filter);
-
-			if (std::string::npos == title.find(cur_filter))
-			{
-				// hide tab if its title doesn't pass filter
-				// and it has no visible items
-				tab->setVisible(list->size() != 0);
-
-				// remove title highlighting because it might
-				// have been previously highlighted by less restrictive filter
-				tab->setTitle(tab->getTitle());
-			}
-			else
-			{
-				tab->setTitle(tab->getTitle(), cur_filter);
-			}
+			applyFilterToTab(iter->first, tab, new_filter_substring);
 
 			if (tab->getVisible())
 			{
@@ -608,10 +585,50 @@ void LLOutfitsList::applyFilter(const std::string& new_filter_substring)
 
 			//restore accordion state after all those accodrion tab manipulations
 			tab->notifyChildren(LLSD().with("action","restore_state"));
+
+			// Try restoring the tab selection.
+			restoreOutfitSelection(tab, iter->first);
 		}
 	}
 }
 
+void LLOutfitsList::applyFilterToTab(
+	const LLUUID&		category_id,
+	LLAccordionCtrlTab*	tab,
+	const std::string&	filter_substring)
+{
+	if (!tab) return;
+	LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView());
+	if (!list) return;
+
+	std::string title = tab->getTitle();
+	LLStringUtil::toUpper(title);
+
+	std::string cur_filter = filter_substring;
+	LLStringUtil::toUpper(cur_filter);
+
+	tab->setTitle(tab->getTitle(), cur_filter);
+
+	if (std::string::npos == title.find(cur_filter))
+	{
+		// hide tab if its title doesn't pass filter
+		// and it has no visible items
+		tab->setVisible(!list->empty());
+
+		// remove title highlighting because it might
+		// have been previously highlighted by less restrictive filter
+		tab->setTitle(tab->getTitle());
+
+		// Remove the tab from selection.
+		deselectOutfit(category_id);
+	}
+	else
+	{
+		// Try restoring the tab selection.
+		restoreOutfitSelection(tab, category_id);
+	}
+}
+
 void LLOutfitsList::onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id)
 {
 	LLAccordionCtrlTab* tab = dynamic_cast<LLAccordionCtrlTab*>(ctrl);
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index 5605044f41a59f7f0417584b0b03067edc75804f..33791fbe6214ccb435118fafd6a71ee076b1082a 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -119,6 +119,18 @@ class LLOutfitsList : public LLPanel
 	 */
 	void setSelectedOutfitUUID(const LLUUID& category_id);
 
+	/**
+	 * Removes the outfit from selection.
+	 */
+	void deselectOutfit(const LLUUID& category_id);
+
+	/**
+	 * Try restoring selection for a temporary hidden tab.
+	 *
+	 * A tab may be hidden if it doesn't match current filter.
+	 */
+	void restoreOutfitSelection(LLAccordionCtrlTab* tab, const LLUUID& category_id);
+
 	/**
 	 * Called upon list refresh event to update tab visibility depending on
 	 * the results of applying filter to the title and list items of the tab.
@@ -130,6 +142,13 @@ class LLOutfitsList : public LLPanel
 	 */
 	void applyFilter(const std::string& new_filter_substring);
 
+	/**
+	 * Applies filter to the given tab
+	 *
+	 * @see applyFilter()
+	 */
+	void applyFilterToTab(const LLUUID& category_id, LLAccordionCtrlTab* tab, const std::string& filter_substring);
+
 	void onAccordionTabRightClick(LLUICtrl* ctrl, S32 x, S32 y, const LLUUID& cat_id);
 	void onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y);
 	void onCOFChanged();