Skip to content

Commit

Permalink
Merge pull request #221 from ONSdigital/fix-option-values-data-version
Browse files Browse the repository at this point in the history
Fix option values for data versions
  • Loading branch information
farres1 authored Oct 30, 2024
2 parents 95ef225 + f931acf commit f5d496a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ const getOptionValues = (optionIds, questionnaire) => {
const optionResults = optionIds.map((id) => {
const option = find(options, { id });

const optionContent = option.value
? option.value.trim()
: option.label.trim();
const optionContent =
questionnaire.dataVersion === "3" && option.value
? option.value.trim()
: option.label.trim();

const updatedContent = optionContent
.replace(/'/g, `\u2019`)
Expand Down
3 changes: 2 additions & 1 deletion src/eq_schema/schema/Answer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ class Answer {
{ properties, type },
ctx
) {
const optionValue = value ? value : label;
const optionValue =
ctx && ctx.questionnaireJson.dataVersion === "3" && value ? value : label;
const option = {
label: buildContents(label, ctx, true),
value: buildContents(optionValue, ctx, true),
Expand Down

0 comments on commit f5d496a

Please sign in to comment.