Skip to content

Commit

Permalink
Fix success message not shown
Browse files Browse the repository at this point in the history
Fixes: AFORM-3860
  • Loading branch information
epi-qang2 committed Feb 5, 2024
1 parent 183ea56 commit 91ac781
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/@episerver/forms-react/src/components/FormBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const FormBody = (props: FormBodyProps) => {
const formTitleId = `${form.key}_label`;
const statusMessage = useRef<string>("");
const statusDisplay = useRef<string>("hide");

const showForm = useRef<boolean>(true);

const formCache = new FormCache();
const localFormCache = new FormCache(window.localStorage);
Expand Down Expand Up @@ -140,10 +142,14 @@ export const FormBody = (props: FormBodyProps) => {
dispatchFunctions.updateSubmissionKey(response.submissionKey);
localFormCache.set(submissionStorageKey, response.submissionKey);

if (isProgressiveSubmit.current) {
message.current = response.messages.map(m => m.message).join("<br>");
showForm.current = false
}

if (isFormFinalized.current) {
formCache.remove(FormConstants.FormCurrentStep + form.key);
localFormCache.remove(submissionStorageKey);
message.current = response.messages.map(m => m.message).join("<br>");
//redirect after submit
let redirectToPage = submitButton?.properties?.redirectToPage ?? form.properties?.redirectToPage;
if (!isNullOrEmpty(redirectToPage)) {
Expand Down Expand Up @@ -234,7 +240,7 @@ export const FormBody = (props: FormBodyProps) => {
</div>
</div>

<div className="Form__MainBody">
<div className="Form__MainBody" style={{display: showForm.current ? 'flow' : 'none' }}>
{/* render element */}
{form.steps.map((e, i) => {
let stepDisplaying = (currentStepIndex === i && !isFormFinalized.current && isStepValidToDisplay && !isMalFormSteps) ? "" : "hide";
Expand Down

0 comments on commit 91ac781

Please sign in to comment.