Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form]: Unable to use requestSubmit in v2 #9891

Closed
1 task done
Nemin32 opened this issue Sep 17, 2024 · 5 comments · Fixed by #9933
Closed
1 task done

[Form]: Unable to use requestSubmit in v2 #9891

Nemin32 opened this issue Sep 17, 2024 · 5 comments · Fixed by #9933
Assignees
Labels
bug This issue is a bug in the code documentation This issue is about wrong documentation Medium Prio TOPIC Core

Comments

@Nemin32
Copy link

Nemin32 commented Sep 17, 2024

Describe the bug

Hello,

We've been using UI5 v1 in our project and have relied on the UI5 Form component acting as an actual HTML <form> component, which may be submitted using the requestSubmit method called on the form's ref. However, during our migration to v2, we experienced unusual fatal errors which we tracked down to requestSubmit being undefined.

From what we could find, the new ui5-form element doesn't support submitting with either the requestSubmit method, a Button component set to type="Submit", or by calling dispatchEvent. Instead it relies on a call to _internals.form.requestSubmit() (see here) which also doesn't work, because the _internals.form elem remains null. This is also a problem, because we rely on React Hook Form, which needs a proper form to work.

This is currently blocking us from finishing the upgrade. The migration docs mention the Form element being a drop-in replacement to the v1 variant, so I would kindly ask for your help how to make the new component work with our workflow.

Thank you for your assistance.

Isolated Example

No response

Reproduction steps

  1. Navigate to this example page
  2. Fill out the form
  3. Click submit
  4. Nothing happens.

Expected Behaviour

The contents of the form are alerted out to the user, due to the onSubmit event firing.

Screenshots or Videos

No response

UI5 Web Components for React Version

2.1.0

UI5 Web Components Version

2.2.0

Browser

Firefox

Operating System

MacOSX 15

Additional Context

No response

Relevant log output

No response

Organization

SAP

Declaration

  • I’m not disclosing any internal or sensitive information.
@Nemin32 Nemin32 added the bug This issue is a bug in the code label Sep 17, 2024
@Lukas742
Copy link
Collaborator

Hi @Nemin32

unfortunately our Form Handling section is outdated, until we've updated it I will hide it from the Storybook for v2. Sorry for the inconvenience.

I'll forward this issue to our UI5 Web Components Colleagues as the affected component is developed in their repository.

As a workaround, you can wrap your Form component in an html form and apply all logic there (e.g. onSubmit). Here you can find an example of how this could be achieved: https://stackblitz.com/edit/github-mh8hto?file=src%2FApp.tsx


Hi Colleagues,

please check if the Form should behave like an actual HTML form element. If not, this should probably be outlined in the documentation.

I've prepared an StackBlitz example showing the differences between a form, a ui5-form and a ui5-form wrapped inside a form: https://stackblitz.com/edit/github-ltccua?file=main.js,index.html,package.json

@Lukas742 Lukas742 transferred this issue from SAP/ui5-webcomponents-react Sep 18, 2024
@IlianaB
Copy link
Member

IlianaB commented Sep 18, 2024

Hello @SAP/ui5-webcomponents-topic-core , please check out this issue about requestSubmit method not being supported for ui5-form.

Regards,
Iliana

@Nemin32
Copy link
Author

Nemin32 commented Sep 18, 2024

Hi, thank you for the quick reply! @Lukas742 your workaround works great, we're able to proceed.

@nnaydenow
Copy link
Contributor

Hi @Nemin32,

as @Lukas742 said the ui5-form component doesn't come with build in form html element inside it. It is used as layout component that arranges labels and form fields (like input fields) pairs into a specific number of columns.

Everyone is using forms in its own way so we left this to be handled separately with the solution that Lukas provided.

We will revise the description of the component to give more clear statement about this.

Thanks!

Regards,
Nayden

@nnaydenow nnaydenow added the documentation This issue is about wrong documentation label Sep 19, 2024
@ilhan007
Copy link
Member

ilhan007 commented Sep 25, 2024

Hi @Nemin32, @Lukas742

The Form web component is a layout, it isn't a replacement for the form HTML element. The Form web component does not provide any APIs for form submission and this is now stated explicitly with this PR.

What Lukas suggested above is the way to go.

@ilhan007 ilhan007 self-assigned this Sep 25, 2024
ilhan007 added a commit that referenced this issue Sep 26, 2024
The Form web component is a layout, it isn't a replacement for the form HTML element. The Form web component does not provide any APIs for form submission

Fixes: #9891
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug in the code documentation This issue is about wrong documentation Medium Prio TOPIC Core
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

5 participants