Properly selecting tabs containing an error
authorAlexander Ebert <ebert@woltlab.com>
Thu, 27 Feb 2014 13:30:29 +0000 (14:30 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 27 Feb 2014 13:30:29 +0000 (14:30 +0100)
wcfsetup/install/files/js/WCF.js

index 8bcf58f4a7f7806814f93c1ba9b8b78b23f80381..b9b3021afde37a32ec75b4420098b021609f73b6 100755 (executable)
@@ -3797,19 +3797,47 @@ WCF.TabMenu = {
         * @return      boolean
         */
        _selectErroneousTab: function() {
+               var $foundErrors = false;
                for (var $containerID in this._containers) {
                        var $tabMenu = this._containers[$containerID];
                        
-                       if (!$tabMenu.data('isParent') && $tabMenu.find('.formError').length) {
-                               while (true) {
-                                       if ($tabMenu.data('parent') === false) {
-                                               break;
+                       if ($tabMenu.find('.formError').length) {
+                               $foundErrors = true;
+                               
+                               if (!$tabMenu.data('isParent')) {
+                                       while (true) {
+                                               if ($tabMenu.data('parent') === false) {
+                                                       break;
+                                               }
+                                               
+                                               $tabMenu = $tabMenu.data('parent').wcfTabs('selectTab', $tabMenu.wcfIdentify());
                                        }
                                        
-                                       $tabMenu = $tabMenu.data('parent').wcfTabs('selectTab', $tabMenu.wcfIdentify());
+                                       return true;
                                }
+                       }
+               }
+               
+               // found an error in a non-nested tab menu
+               if ($foundErrors) {
+                       for (var $containerID in this._containers) {
+                               var $tabMenu = this._containers[$containerID];
+                               var $formError = $tabMenu.find('.formError:eq(0)');
                                
-                               return true;
+                               if ($formError.length) {
+                                       // find the tab container
+                                       $tabMenu.wcfTabs('selectTab', $formError.parents('.tabMenuContent').wcfIdentify());
+                                       
+                                       while (true) {
+                                               if ($tabMenu.data('parent') === false) {
+                                                       break;
+                                               }
+                                               
+                                               $tabMenu = $tabMenu.data('parent').wcfTabs('selectTab', $tabMenu.wcfIdentify());
+                                       }
+                                       
+                                       return true;
+                               }
                        }
                }