Skip to content

Add info text to matrix responses#1038

Merged
jaykim1213 merged 10 commits intodevfrom
jk/infoText
Feb 20, 2026
Merged

Add info text to matrix responses#1038
jaykim1213 merged 10 commits intodevfrom
jk/infoText

Conversation

@jaykim1213
Copy link
Copy Markdown
Contributor

@jaykim1213 jaykim1213 commented Feb 19, 2026

Does this PR close any open issues?

Closes #1035

Give a longer description of what this PR addresses and why it's needed

Add info text to matrix responses (question, option)

Provide pictures/videos of the behavior before and after these changes (optional)

Screenshot 2026-02-19 at 1 21 44 PM

Are there any additional TODOs before this PR is ready to go?

TODOs:

  • Update relevant documentation
  • [ ]

@jaykim1213 jaykim1213 linked an issue Feb 19, 2026 that may be closed by this pull request
@jaykim1213 jaykim1213 changed the base branch from main to dev February 19, 2026 20:23
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 19, 2026

🪓 PR closed, deleted preview.

@jaykim1213 jaykim1213 marked this pull request as ready for review February 19, 2026 20:26
@jaykim1213 jaykim1213 added this to the v2.4 milestone Feb 19, 2026
@JackWilb JackWilb requested review from JackWilb and Copilot and removed request for Copilot February 20, 2026 21:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds option-level “info text” support across response components, including matrix question/answer options, by allowing richer StringOption objects (with optional value) and updating UI rendering/normalization accordingly.

Changes:

  • Extend matrix answerOptions/questionOptions to accept StringOption entries and render infoText via OptionLabel.
  • Make StringOption.value optional (defaulting to label) and normalize option values across inputs and randomization.
  • Update JSON schemas and demo survey config to reflect the new option shapes.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/handleResponseRandomization.ts Normalizes option/question values when randomizing to support StringOption without explicit value.
src/parser/types.ts Makes StringOption.value optional; extends matrix option types to allow StringOption.
src/parser/StudyConfigSchema.json Updates schema to allow matrix options as string or StringOption; makes StringOption.value optional.
src/parser/LibraryConfigSchema.json Mirrors schema updates (matrix options + StringOption changes) and adds clickToRecord fields.
src/components/response/utils.ts Adjusts matrix init-field generation for updated question option shapes (currently with a keying issue).
src/components/response/ResponseSwitcher.tsx Initializes matrix fields using value ?? label for question keys.
src/components/response/RankingInput.tsx Normalizes ranking option ids/values to handle missing value.
src/components/response/RadioInput.tsx Normalizes radio option values and renders infoText in labels.
src/components/response/MatrixInput.tsx Renders infoText for matrix rows/columns and normalizes question/answer values.
src/components/response/DropdownInput.tsx Adds renderOption with OptionLabel to show option infoText in dropdowns.
src/components/response/CheckBoxInput.tsx Normalizes checkbox option values and keys to handle missing value.
src/components/response/ButtonsInput.tsx Renders option labels with OptionLabel and normalizes option values.
src/analysis/individualStudy/summary/utils.tsx Formats matrix response option summaries when options are StringOption objects.
public/demo-survey/config.json Updates demo config to use label/infoText objects (omitting value) for several responses, including matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/response/utils.ts Outdated
Comment thread src/components/response/ButtonsInput.tsx
Comment thread src/analysis/individualStudy/summary/utils.tsx
Comment thread src/parser/LibraryConfigSchema.json
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +209 to +220
<Box
key={`choice-${idx}-label`}
style={{
fontWeight: 'bold',
textAlign: 'center',
fontSize: '0.8em',
}}
mb="sm"
ml="xs"
mr="xs"
>
{entry.label}
</Text>
<OptionLabel label={entry.label} infoText={entry.infoText} />
</Box>
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of fontWeight: 'bold' from the column header styling changes the visual appearance of matrix response column headers. Previously, column headers were displayed in bold text, but now they will appear in regular weight. If this visual change is intentional and aligns with the design in the screenshot, this comment can be disregarded. Otherwise, consider adding fontWeight: 'bold' to the style prop of the Box component or applying it through the OptionLabel component to maintain consistency with the previous design.

Copilot uses AI. Check for mistakes.
Comment thread src/components/response/MatrixInput.tsx Outdated
Comment on lines +142 to +143
const questions = parseStringOptions(response.questionOptions);
const questionsByValue = Object.fromEntries(questions.map((question) => [question.value, question]));
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The questions variable is created on every render without useMemo, and it's used as a dependency in the orderedQuestions useMemo on line 146. This means orderedQuestions will be recalculated on every render even if response.questionOptions hasn't changed, because questions is a new array reference each time. Consider wrapping the parseStringOptions call in useMemo with response.questionOptions as the dependency to avoid unnecessary recalculations.

Copilot uses AI. Check for mistakes.
Comment thread src/components/response/MatrixInput.tsx Outdated
Comment on lines +138 to +140
const _choices: ParsedStringOption[] = typeof answerOptions === 'string'
? parseStringOptions(_choiceStringToColumns[answerOptions])
: parseStringOptions(answerOptions);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _choices variable is created on every render without useMemo. Since it's used in the onChangeCheckbox function which is passed to child components, this could cause unnecessary re-renders of CheckboxComponent. Consider wrapping the _choices calculation in useMemo with answerOptions as a dependency to improve performance, especially for large matrices.

Suggested change
const _choices: ParsedStringOption[] = typeof answerOptions === 'string'
? parseStringOptions(_choiceStringToColumns[answerOptions])
: parseStringOptions(answerOptions);
const _choices: ParsedStringOption[] = useMemo(
() => (typeof answerOptions === 'string'
? parseStringOptions(_choiceStringToColumns[answerOptions])
: parseStringOptions(answerOptions)),
[answerOptions],
);

Copilot uses AI. Check for mistakes.
Comment thread src/parser/LibraryConfigSchema.json
@jaykim1213 jaykim1213 merged commit 8a2408a into dev Feb 20, 2026
5 of 8 checks passed
@jaykim1213 jaykim1213 deleted the jk/infoText branch February 20, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Info text icon in the matrix components - also button components

3 participants