Skip to content

Commit cd02ead

Browse files
authored
fix(input like): correct form submission behaviour (#12959)
All text-based input components (except textarea) now trigger a change event before requesting form submission. - Pressing Enter on an empty field requests form submission. - Pressing Enter on a field with a value also requests submission. - For inputs that require user confirmation (typeahead, input suggestions, date picker, etc.), the first Enter confirms the value, while a second Enter triggers the form submission. Added form submission support to ui5-step-input. Added tests for all components implementing this behavior.
1 parent b6c582c commit cd02ead

16 files changed

+1081
-167
lines changed

packages/base/src/features/InputElementsFormSupport.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const setFormValue = (element: IFormInputElement) => {
3030
};
3131

3232
const setFormValidity = async (element: IFormInputElement) => {
33-
if (!element._internals?.form) {
33+
if (!element.isUI5Element || !element._internals?.form) {
3434
return;
3535
}
3636

@@ -45,7 +45,11 @@ const setFormValidity = async (element: IFormInputElement) => {
4545
}
4646
};
4747

48-
const submitForm = (element: UI5Element) => {
48+
const submitForm = async (element: UI5Element) => {
49+
const elements = [...(element._internals?.form?.elements ?? [])] as Array<IFormInputElement | UI5Element>;
50+
51+
await Promise.all(elements.map(el => { return isInputElement(el) ? setFormValidity(el) : Promise.resolve(); }));
52+
4953
element._internals?.form?.requestSubmit();
5054
};
5155

0 commit comments

Comments
 (0)