diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index 951323551c0ae61e766b48e978e0e209b53d738b..7a7ffb998382c95c8ab082576ad70d6c0f9062e6 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -196,6 +196,15 @@ void LLSidepanelAppearance::onVisibilityChange(const LLSD &new_visibility)
 			{
 				gAgentCamera.changeCameraToCustomizeAvatar();
 			}
+			if (mEditWearable && mEditWearable->getVisible())
+			{
+				LLWearable *wearable_ptr = mEditWearable->getWearable();
+				if (gAgentWearables.getWearableIndex(wearable_ptr) == LLAgentWearables::MAX_CLOTHING_PER_TYPE)
+				{
+					// we're no longer wearing the wearable we were last editing, switch back to outfit editor
+					showOutfitEditPanel();
+				}
+			}
 		}
 	}
 	else