Skip to content

[🐞] onSubmitCompleted$ is always triggered, even when fails #300

@keuller

Description

@keuller

Which component is affected?

Qwik Runtime

Describe the bug

According to the documentation onSubmitCompleted$ should be executed right after the action is executed successfully and returns some data. The issue: it is always executed no matter Zod validation fails or I return fail inside actionRoute$.

Reproduction

N/A

Steps to reproduce

You can use this code:

import { component$ } from '@builder.io/qwik';
import { Form, routeAction$, zod$, z } from '@builder.io/qwik-city';

export const useSaveAction = routeAction$(async (lead, { request, fail }) => {
    console.log('lead:', lead);
    
    return {
    }
}, zod$({
    name: z.string().min(3),
    email: z.string().email(),
}));

export default component$(() => {
   const action = useSaveAction();

   return (
   <Form id='leadForm' action={action}
           onSubmitCompleted$={(ev) => console.log('onSubmitCompleted', ev.detail)}>

      <label for="id" class="text-sm text-slate-500">{ props.label }</label>
       <input type="text" name="name"
            class="border border-slate-500 rounded-md p-2" 
            maxLength={50} />

       <input type="email" name="email"
            class="border border-slate-500 rounded-md p-2" 
            maxLength={100} />

      <div class="col-span-2 py-2">
          <button type="submit" name="_intent" 
              value="create"
              disabled={action.isRunning}
              class="outline-none bg-indigo-500 hover:bg-indigo-600 px-6 py-2 rounded-md text-sm text-white disabled:bg-slate-400">
              <span>{action.isRunning ? 'Saving...' : 'Save'}</span>
          </button>
       </div>
   </Form>)
});

### System Info

```shell
System: Mac OSX Ventura 13.3
Qwik version: 1.1.4
Qwik-City: 1.1.4
Typescript: 5.0.4
Node: 16.15.0

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions