Skip to content

Commit 57adb04

Browse files
authored
fix: enable form support for nested input elements (#656)
1 parent 7548ed0 commit 57adb04

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

packages/main/src/features/InputElementsFormSupport.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ class FormSupport {
3030
if (!element.submits) {
3131
return;
3232
}
33-
let parentElement;
34-
do {
35-
parentElement = element.parentElement;
36-
} while (parentElement && parentElement.tagName.toLowerCase() !== "form");
37-
if (parentElement) {
38-
parentElement.submit();
33+
let currentElement = element.parentElement;
34+
while (currentElement && currentElement.tagName.toLowerCase() !== "form") {
35+
currentElement = currentElement.parentElement;
36+
}
37+
if (currentElement) {
38+
currentElement.submit();
39+
} else {
40+
console.error(`${element} is not within a form. Please add it in a form.`); // eslint-disable-line
3941
}
4042
}
4143
}

packages/main/test/sap/ui/webcomponents/main/pages/FormSupport.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737

3838

3939
</body>
40-
</html>
40+
</html>

packages/main/test/specs/FormSupport.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ describe("Form support", () => {
2121
submitButton.click();
2222

2323
const formWasSubmitted = browser.execute(() => {
24-
const expectedFormData = "FormSupport.html?input=ok&ta=ok&dp=Apr+10%2C+2019&cb=on&radio=b";
24+
const expectedFormData = "?input=ok&ta=ok&dp=Apr+10%2C+2019&cb=on&radio=b";
2525
return location.href.endsWith(expectedFormData);
2626
});
2727
assert.ok(formWasSubmitted, "For was submitted and URL changed");
2828
});
2929

30-
});
30+
});

0 commit comments

Comments
 (0)