Skip to content

Commit

Permalink
👻 conditional rendering to fix stale wizard state
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Oct 18, 2023
1 parent a7d5d84 commit dfc524d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion client/src/app/pages/assessment/assessment-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const AssessmentPage: React.FC = () => {
)}
<AssessmentWizard
assessment={assessment}
isOpen
isLoadingAssessment={isFetching}
/>
</PageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -60,13 +65,11 @@ export interface AssessmentWizardValues {

export interface AssessmentWizardProps {
assessment?: Assessment;
isOpen: boolean;
isLoadingAssessment: boolean;
}

export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({
assessment,
isOpen,
isLoadingAssessment,
}) => {
const isArchetype = useIsArchetype();
Expand Down Expand Up @@ -97,8 +100,8 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({

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
Expand Down Expand Up @@ -583,7 +586,9 @@ export const AssessmentWizard: React.FC<AssessmentWizardProps> = ({

return (
<>
{isOpen && !!sortedSections.length && (
{isLoadingAssessment ? (
<Spinner />
) : (
<FormProvider {...methods}>
<Wizard
isVisitRequired
Expand Down

0 comments on commit dfc524d

Please sign in to comment.