Skip to content

Commit

Permalink
Adjust logic to detect form finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
hungoptimizely committed Dec 14, 2023
1 parent 8cd79c1 commit ad715f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/@episerver/forms-react/src/components/FormBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ export const FormBody = (props: FormBodyProps) => {
statusDisplay.current = "Form__Warning__Message";
statusMessage.current = message.current;
}
const isLastStep = currentStepIndex == stepCount - 1;
const validationCssClass = validateFail.current ? "ValidationFail" : "ValidationSuccess";
const isShowStepNavigation = stepCount > 1 && currentStepIndex > -1 && currentStepIndex < stepCount && !isFormFinalized.current;
const prevButtonDisableState = (currentStepIndex == 0) || !submittable;
const nextButtonDisableState = (currentStepIndex == stepCount - 1) || !submittable;
const nextButtonDisableState = isLastStep || !submittable;
const currentDisplayStepIndex = currentStepIndex + 1;
const progressWidth = (100 * currentDisplayStepIndex / stepCount) + "%";

Expand Down Expand Up @@ -90,7 +91,7 @@ export const FormBody = (props: FormBodyProps) => {
let model: FormSubmitModel = {
formKey: form.key,
locale: form.locale,
isFinalized: submitButton?.properties?.finalizeForm || formContext?.currentStepIndex === form.steps.length - 1,
isFinalized: submitButton?.properties?.finalizeForm || isLastStep,
partialSubmissionKey: formContext?.submissionKey ?? "",
hostedPageUrl: window.location.pathname,
submissionData: formSubmissions,
Expand All @@ -111,7 +112,8 @@ export const FormBody = (props: FormBodyProps) => {


validateFail.current = response.validationFail;
isFormFinalized.current = isSuccess.current = response.success;
isSuccess.current = response.success;
isFormFinalized.current = isLastStep && response.success;
dispatchFunctions.updateSubmissionKey(response.submissionKey);
dispatchFunctions.updateIsSubmitting(false);
});
Expand Down

0 comments on commit ad715f5

Please sign in to comment.