--- a/features.js
+++ b/features.js
@@ -348,30 +348,30 @@ jQuery.fn.sortElements = (function(){
         // collapse fieldsets
         var newState = {};
         var currentState = {};
-        $('#features-export-wrapper .component-select label', context).each(function() {
+        $('#features-export-wrapper fieldset.features-export-component', context).each(function() {
           // expand parent fieldset
-          var section = '';
-          $(this).parents('fieldset.features-export-component').each(function() {
-            section = $(this).attr('id');
-            currentState[section] = !($(this).hasClass('collapsed'));
-            if (!(section in newState)) {
-              newState[section] = false;
+          var section = $(this).attr('id');
+          currentState[section] = !($(this).hasClass('collapsed'));
+          if (!(section in newState)) {
+            newState[section] = false;
+          }
+
+          $(this).find('div.component-select label').each(function() {
+            if (filter == '') {
+              if (currentState[section]) {
+                Drupal.toggleFieldset($('#'+section));
+                currentState[section] = false;
+              }
+              $(this).parent().show();
             }
-          });
-          if (filter == '') {
-            if (currentState[section]) {
-              Drupal.toggleFieldset($('#'+section));
-              currentState[section] = false;
+            else if ($(this).text().match(regex)) {
+              $(this).parent().show();
+              newState[section] = true;
             }
-            $(this).parent().show();
-          }
-          else if ($(this).text().match(regex)) {
-            $(this).parent().show();
-            newState[section] = true;
-          }
-          else {
-            $(this).parent().hide();
-          }
+            else {
+              $(this).parent().hide();
+            }
+          });
         });
         for (section in newState) {
           if (currentState[section] != newState[section]) {
