Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Form cannot be resubmitted after an error thrown in onSubmit #418

@malash

Description

@malash

The Form component support throwing error in its onSubmit callback and renders the error message. But I my application, the FormAction is not reset to enabled even if I modify the input.

Full example: https://codesandbox.io/s/trusting-brown-42suu

Root cause:

return <BaseFormActions {...props} disabled={!valid} processing={submitting} />;

A possible solution:

export default function FormActions(props: FormActionsProps) {
  const form = useForm();
  // this line changed
  const { submitting, valid, dirtySinceLastSubmit } = form.getState();

  return (
    <BaseFormActions
      {...props}
      // this line changed
      disabled={!dirtySinceLastSubmit && !valid}
      processing={submitting}
    />
  );
}

Ref: final-form/final-form#48 (comment)

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