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

Javascript error on submit for an invalid form #2586

Closed
jcgueriaud1 opened this issue Jun 28, 2024 · 1 comment · Fixed by vaadin/docs#3823
Closed

Javascript error on submit for an invalid form #2586

jcgueriaud1 opened this issue Jun 28, 2024 · 1 comment · Fixed by vaadin/docs#3823
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation hilla Issues related to Hilla

Comments

@jcgueriaud1
Copy link

Describe the bug

When I submit a form that is invalid I have a javascript error.

Uncaught (in promise) ValidationError: There are validation errors in the form.
 - fullName - NotNull: must not be null
    at BinderRoot.submitTo (chunk-UA3PFYSQ.js?v=5a255b3a:1929:13)

Expected-behavior

I don't expect a javascript error for a validation error that is handled in my form.
Especially because the documentation says:

Submission failures are handled automatically, so there is no need to do an explicit try-catch.

https://vaadin.com/docs/latest/hilla/guides/forms/binder-load#saving-data

Reproduction

Run this project:
https://github.com/jcgueriaud1/hilla-example-form

Go to the home page and click on save, see the error in the console.

System Info

Vaadin 24.4.4

@jcgueriaud1 jcgueriaud1 added bug Something isn't working hilla Issues related to Hilla labels Jun 28, 2024
@cromoteca
Copy link
Contributor

cromoteca commented Jul 9, 2024

The current behavior handles validation errors, but the main error itself is not handled and goes to the browser, which puts it in the console.
Either we add some default handling, or we change the documentation to better explain what happens.
An example of full handling is in the AutoForm.
Let's update the documentation and maybe add a simple example of error handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation hilla Issues related to Hilla
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants