Skip to content

Commit

Permalink
Adjust logic to show message
Browse files Browse the repository at this point in the history
  • Loading branch information
hungoptimizely committed Dec 14, 2023
1 parent 75005a2 commit 8cd79c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/@episerver/forms-react/src/components/FormBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const FormBody = (props: FormBodyProps) => {
currentStepIndex = formContext?.currentStepIndex ?? 0,
isStepValidToDisplay = true;

if(isSuccess.current && isFormFinalized.current)
if((isFormFinalized.current || isProgressiveSubmit.current) && isSuccess.current)
{
statusDisplay.current = "Form__Success__Message";
statusMessage.current = form.properties.submitSuccessMessage ?? message.current;
Expand All @@ -47,7 +47,7 @@ export const FormBody = (props: FormBodyProps) => {
statusMessage.current = message.current;
}
const validationCssClass = validateFail.current ? "ValidationFail" : "ValidationSuccess";
const isShowStepNavigation = stepCount > 1 && currentStepIndex > -1 && currentStepIndex < stepCount && !isFormFinalized;
const isShowStepNavigation = stepCount > 1 && currentStepIndex > -1 && currentStepIndex < stepCount && !isFormFinalized.current;
const prevButtonDisableState = (currentStepIndex == 0) || !submittable;
const nextButtonDisableState = (currentStepIndex == stepCount - 1) || !submittable;
const currentDisplayStepIndex = currentStepIndex + 1;
Expand All @@ -64,7 +64,7 @@ export const FormBody = (props: FormBodyProps) => {
let buttonId = e.nativeEvent.submitter.id;
let submitButton = form.formElements.filter(fe => fe.key === buttonId)[0] as SubmitButton;
if(!isNull(submitButton)){
//when submitting by SubmitButton, isProgressiveSubmit default is true
//when submitting by SubmitButton, then isProgressiveSubmit is true
isProgressiveSubmit.current = true;
}

Expand All @@ -84,7 +84,6 @@ export const FormBody = (props: FormBodyProps) => {
)[0]?.elementKey;
if(!isNullOrEmpty(invalid)){
dispatchFunctions.updateFocusOn(invalid);
isFormFinalized.current = false;
return;
}

Expand All @@ -109,6 +108,8 @@ export const FormBody = (props: FormBodyProps) => {
//ignore validation message
message.current = response.messages.filter(m => isNullOrEmpty(m.identifier)).map(m => m.message).join("<br>");
}


validateFail.current = response.validationFail;
isFormFinalized.current = isSuccess.current = response.success;
dispatchFunctions.updateSubmissionKey(response.submissionKey);
Expand Down

0 comments on commit 8cd79c1

Please sign in to comment.