Select the first erroneous tab in a form if multiple are erroneous
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 5 Jul 2022 07:51:24 +0000 (09:51 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 5 Jul 2022 07:51:24 +0000 (09:51 +0200)
This was incorrectly migrated to TypeScript. Before TypeScript this used a
regular `for` loop counting indices, allowing the `return;` to correctly leave
the loop.

see https://www.woltlab.com/community/thread/296198-formbuilder-tabmenuformcontainer-required-js-fehler/

ts/WoltLabSuite/Core/Ui/TabMenu.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js

index e3988290218b8f0c2f691c926a0b60e811528ef0..d4893bfdfcaf5986119eaefdd25465018252ce6a 100644 (file)
@@ -95,7 +95,7 @@ function init() {
             return;
           }
 
-          container.querySelectorAll("input, select").forEach((element: HTMLInputElement | HTMLSelectElement) => {
+          for (const element of container.querySelectorAll<HTMLInputElement | HTMLSelectElement>("input, select")) {
             if (!element.checkValidity()) {
               event.preventDefault();
 
@@ -109,7 +109,7 @@ function init() {
 
               return;
             }
-          });
+          }
         });
       }
     }
index 092e81adbe89c8b3d89c1a2836a22f91753c999f..5b9f0f0c3ec2920a18c9cbdaa05af1380cb7e134 100644 (file)
@@ -84,7 +84,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Dom/Util",
                         if (event.defaultPrevented) {
                             return;
                         }
-                        container.querySelectorAll("input, select").forEach((element) => {
+                        for (const element of container.querySelectorAll("input, select")) {
                             if (!element.checkValidity()) {
                                 event.preventDefault();
                                 // Select the tab that contains the erroneous element.
@@ -96,7 +96,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Dom/Util",
                                 });
                                 return;
                             }
-                        });
+                        }
                     });
                 }
             }