From 334a6f9930b8e09d90e44b51b19bed30184a1641 Mon Sep 17 00:00:00 2001 From: ibolton336 Date: Thu, 21 Sep 2023 16:26:02 -0400 Subject: [PATCH] :bug: Fully unique ids for answer selections Signed-off-by: ibolton336 --- .../multi-input-selection/multi-input-selection.tsx | 7 +++---- .../components/questionnaire-form/questionnaire-form.tsx | 9 ++++++--- client/src/app/pages/assessment/form-utils.ts | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client/src/app/pages/assessment/components/questionnaire-form/multi-input-selection/multi-input-selection.tsx b/client/src/app/pages/assessment/components/questionnaire-form/multi-input-selection/multi-input-selection.tsx index 5a74d2d966..d2b08203d3 100644 --- a/client/src/app/pages/assessment/components/questionnaire-form/multi-input-selection/multi-input-selection.tsx +++ b/client/src/app/pages/assessment/components/questionnaire-form/multi-input-selection/multi-input-selection.tsx @@ -27,18 +27,17 @@ export const MultiInputSelection: React.FC = ({ const isArchetype = useIsArchetype(); const { t } = useTranslation(); - return ( {sortedOptions.map((option, i) => ( - + ( { diff --git a/client/src/app/pages/assessment/components/questionnaire-form/questionnaire-form.tsx b/client/src/app/pages/assessment/components/questionnaire-form/questionnaire-form.tsx index f352741111..4604f4ddf1 100644 --- a/client/src/app/pages/assessment/components/questionnaire-form/questionnaire-form.tsx +++ b/client/src/app/pages/assessment/components/questionnaire-form/questionnaire-form.tsx @@ -12,7 +12,7 @@ import { import HelpIcon from "@patternfly/react-icons/dist/esm/icons/help-icon"; import { MultiInputSelection } from "./multi-input-selection"; import { Question, QuestionHeader, QuestionBody } from "./question"; -import { getCommentFieldName } from "../../form-utils"; +import { getCommentFieldName, getQuestionFieldName } from "../../form-utils"; import { HookFormPFTextInput } from "@app/components/HookFormPFFields"; import { useFormContext } from "react-hook-form"; import { Section } from "@app/api/models"; @@ -54,7 +54,7 @@ export const QuestionnaireForm: React.FC = ({ {sortedQuestions.map((question) => ( - + @@ -74,7 +74,10 @@ export const QuestionnaireForm: React.FC = ({ - + diff --git a/client/src/app/pages/assessment/form-utils.ts b/client/src/app/pages/assessment/form-utils.ts index 1f2f54deb5..43fcb26f5d 100644 --- a/client/src/app/pages/assessment/form-utils.ts +++ b/client/src/app/pages/assessment/form-utils.ts @@ -15,6 +15,6 @@ export const getCommentFieldName = (section: Section, fullName: boolean) => { }; export const getQuestionFieldName = (question: Question, fullName: boolean) => { - const fieldName = `question-${question.text}`; + const fieldName = `question-${question.order}`; return fullName ? `${QUESTIONS_KEY}.${fieldName}` : fieldName; };