From dfc524d8ae7723abad703827103b040d8871338c Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Wed, 18 Oct 2023 17:27:42 -0400 Subject: [PATCH] :ghost: conditional rendering to fix stale wizard state --- .../app/pages/assessment/assessment-page.tsx | 1 - .../assessment-wizard/assessment-wizard.tsx | 17 +++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/src/app/pages/assessment/assessment-page.tsx b/client/src/app/pages/assessment/assessment-page.tsx index 3bc1f97406..34e21014b0 100644 --- a/client/src/app/pages/assessment/assessment-page.tsx +++ b/client/src/app/pages/assessment/assessment-page.tsx @@ -63,7 +63,6 @@ const AssessmentPage: React.FC = () => { )} diff --git a/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx b/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx index 61a4d0c976..077befeb83 100644 --- a/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx +++ b/client/src/app/pages/assessment/components/assessment-wizard/assessment-wizard.tsx @@ -3,7 +3,12 @@ import React, { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import { FieldErrors, FormProvider, useForm } from "react-hook-form"; -import { ButtonVariant, Wizard, WizardStep } from "@patternfly/react-core"; +import { + ButtonVariant, + Spinner, + Wizard, + WizardStep, +} from "@patternfly/react-core"; import { Assessment, @@ -60,13 +65,11 @@ export interface AssessmentWizardValues { export interface AssessmentWizardProps { assessment?: Assessment; - isOpen: boolean; isLoadingAssessment: boolean; } export const AssessmentWizard: React.FC = ({ assessment, - isOpen, isLoadingAssessment, }) => { const isArchetype = useIsArchetype(); @@ -97,8 +100,8 @@ export const AssessmentWizard: React.FC = ({ const { pushNotification } = React.useContext(NotificationsContext); - const sortedSections = (!isLoadingAssessment && assessment ? assessment.sections : []).sort( - (a, b) => a.order - b.order + const sortedSections = (assessment ? assessment.sections : []).sort( + (a, b) => a.order - b.order ); //TODO: Add comments to the sections when/if available from api @@ -583,7 +586,9 @@ export const AssessmentWizard: React.FC = ({ return ( <> - {isOpen && !!sortedSections.length && ( + {isLoadingAssessment ? ( + + ) : (