0

I am writing Form for updating information. Inside submit function I am sending new information to redux-toolkit state. Form is closing after submitting. However, I want to form must be stay open if state return a error message

onSubmit={form.onSubmit(values => {
                            values = {
                                ...values,
                                included_modules: values.included_modules.map((item: any) => {
                                    return { type: item };
                                }),
                            };
                            dispatch(updatePackage({ id: value?.id, values: values }));
                            if (myPackage.showError === true) {
                                setServerError(myPackage.message);
                            } else {
                                setShowModal(false);
                            }
                        })}
Johann
  • 12,158
  • 11
  • 62
  • 89

1 Answers1

1

You can pass following props to mantine modal to prevent it from closing:

  /** Should modal be closed when outside click was registered? */
  closeOnClickOutside: false;
  /** Should modal be closed when escape is pressed? */
  closeOnEscape: false;
  /** Hides close button if set to false, modal still can be closed with escape key and by clicking outside */
  withCloseButton: false;
  /** Should modal be closed when confirm button is pressed */
  closeOnConfirm: false,
  /** Should modal be closed when cancel button is pressed */
  closeOnCancel: false,