From 1b4d05ed0e263b6c58589036e5836e731ef7c7bc Mon Sep 17 00:00:00 2001 From: June Zhao <60997220+junjun107@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:05:34 -0700 Subject: [PATCH] Fix correction form reset (#1825) --- .../StakeholderDetails/CorrectionDialog.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/CorrectionDialog.js b/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/CorrectionDialog.js index d3b5774fa..417359c05 100644 --- a/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/CorrectionDialog.js +++ b/client/src/components/FoodSeeker/SearchResults/StakeholderDetails/CorrectionDialog.js @@ -21,8 +21,11 @@ function SuggestionDialog(props) { const { values, touched, errors, handleChange, handleBlur, handleSubmit } = props; - const { onClose, open, id } = props; - const handleCancel = () => onClose(false); + const { onClose, open, id, handleReset } = props; + const handleCancel = () => { + handleReset(); + onClose(false); + }; return ( { + handleSubmit: (values, formikBag) => { const stakeholder = { ...DEFAULT_STAKEHOLDER, - ...props.stakeholder, + ...formikBag.stakeholder, }; // Construct the suggestion by starting with the stakeholder record, @@ -164,13 +167,14 @@ const SuggestionForm = withFormik({ return suggestionService .post(altered) .then(() => { - props.setToast({ + formikBag.props.setToast({ message: "Thank you for your help!", }); - props.onClose(true); + formikBag.resetForm(); + formikBag.props.onClose(true); }) .catch(() => { - props.setToast({ + formikBag.props.setToast({ message: "Sorry, submitting your correction failed, please email us at the address on the About page.", });