Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: M2-8294 Single selection per row: The user remains on the input screen after selecting the response and tapping 'Next' #912

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/features/pass-survey/model/AnswerValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
ChaconC marked this conversation as resolved.
Show resolved Hide resolved
return selectedOption !== null && !selectedOption.includes(optionValue);
},

Expand Down
Loading