From 34079e9c5f7671eb575eb099fb35f9f0ad554a1c Mon Sep 17 00:00:00 2001 From: felipeMetaLab Date: Thu, 5 Dec 2024 09:12:44 -0800 Subject: [PATCH] fix: The user remains on the input screen after selecting the response and tapping 'Next' M2-8294 (#912) Co-authored-by: Felipe Imperio --- .../pass-survey/model/AnswerValidator.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/features/pass-survey/model/AnswerValidator.ts b/src/features/pass-survey/model/AnswerValidator.ts index 24135ec47..126350464 100644 --- a/src/features/pass-survey/model/AnswerValidator.ts +++ b/src/features/pass-survey/model/AnswerValidator.ts @@ -112,6 +112,19 @@ export function AnswerValidator( return null; }; + const getSelectionRowOptionValue = (rowIndex: number): string | null => { + const answer = currentAnswer?.answer as Maybe< + { id: string; text: string }[] + >; + + if (answer && answer[rowIndex]) { + const optionIds = answer[rowIndex].id; + + return optionIds; + } + return null; + }; + return { isCorrect() { if (!currentPipelineItem?.validationOptions) { @@ -164,12 +177,12 @@ export function AnswerValidator( }, isEqualToRowOption(rowIndex: number, optionValue: string) { - const selectedOption = getRowOptionValues(rowIndex); + const selectedOption = getSelectionRowOptionValue(rowIndex); return selectedOption !== null && selectedOption.includes(optionValue); }, isNotEqualToRowOption(rowIndex: number, optionValue: string) { - const selectedOption = getRowOptionValues(rowIndex); + const selectedOption = getSelectionRowOptionValue(rowIndex); return selectedOption !== null && !selectedOption.includes(optionValue); },