'Mantine form, prevent closing mantine modal after submitting
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);
}
})}
Solution 1:[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,
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mateusz Kifner |
