Skip to content

At 100/quiz option description websitejs libraryui library#292

Merged
esezen merged 12 commits into
Constructor-io:mainfrom
dmitrycnstrc:AT-100/quiz-option-description-websitejs-libraryui-library
Jun 1, 2026
Merged

At 100/quiz option description websitejs libraryui library#292
esezen merged 12 commits into
Constructor-io:mainfrom
dmitrycnstrc:AT-100/quiz-option-description-websitejs-libraryui-library

Conversation

@dmitrycnstrc

@dmitrycnstrc dmitrycnstrc commented May 7, 2026

Copy link
Copy Markdown
Contributor

Add support for displaying option-level descriptions in single-select quiz questions
When a single option with a description is selected, the question description area shows the option's description instead of the question-level description
Disable auto-advance to next question when the selected option has a description (user must click Continue)

Test plan

  • Single-select question: click option with description → description text updates to option's description
  • Single-select question: click option without description → shows original question description
  • Single-select question with description option: auto-advance does NOT trigger, user clicks Continue
  • Single-select question without description options: auto-advance works as before
  • Multiple-select questions: no behavior change
  • Cover/OpenText questions: no behavior change

Copilot AI review requested due to automatic review settings May 7, 2026 14:11
@dmitrycnstrc dmitrycnstrc requested a review from a team as a code owner May 7, 2026 14:11
@dmitrycnstrc

Copy link
Copy Markdown
Contributor Author

@claude

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for showing option-level descriptions for single-select quiz questions and prevents auto-advance when the selected option includes a description.

Changes:

  • Added getDisplayedDescription to choose between question vs. selected-option description for single-select questions.
  • Updated useSelectInputProps to expose selected state and to block auto-advance when an option description is present.
  • Propagated selected-option state through context/types and added Storybook + mock data for option descriptions.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/utils.tsx Adds helper to compute the displayed description based on selection.
src/types.ts Introduces shared Selected type and exposes selected options on the quiz return type.
src/stories/Quiz/tests/mocks.tsx Adds mock options with descriptions and wires selected state into mock context.
src/stories/Quiz/Component/QuestionTypes/SingleSelectQuestion.stories.tsx Adds story variant for options with descriptions.
src/hooks/usePropsGetters/useSelectInputProps.ts Returns { getSelectInputProps, selected } and blocks auto-advance for described options.
src/hooks/usePropsGetters/index.ts Passes selected through props-getters output.
src/components/SelectTypeQuestion/SelectTypeQuestion.tsx Uses computed description instead of always using question description.
src/components/CioQuiz/index.tsx Passes selected-options state through context provider value.
src/components/CioQuiz/context.ts Adds selected-options state to context type.
spec/hooks/usePropsGetters/useSelectInputProps/useSelectInputProps.test.tsx Updates tests to match new hook return shape.

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

Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts
Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts
Comment thread src/utils.tsx Outdated
Comment thread src/utils.tsx
Comment thread src/components/SelectTypeQuestion/SelectTypeQuestion.tsx Outdated
dmitrycnstrc added 2 commits May 7, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 10 out of 10 changed files in this pull request and generated 2 comments.

Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts
Comment thread src/utils.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 11 out of 11 changed files in this pull request and generated no new comments.

@Alexey-Pavlov Alexey-Pavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for working on this! Left just a few comments

export interface Selected {
[key: number]: boolean;
}
export type { Selected };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this re-export really necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, it's pre-existing, but it looks like this ref should be a boolean, not an object; it's later assigned true and checked as a boolean.

Suggested change
const singleSelectClicked = useRef(false);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread src/utils.tsx Outdated
question: Question | null | undefined,
selected: Selected
): string | undefined {
if (!question?.description && !question?.options) return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!question?.description && !question?.options) return undefined;
if (!question) return undefined;

What if we use a simpler guard here? Downstream logic handles all the nullable paths already

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread spec/utils/utils.test.ts Outdated
Comment on lines +291 to +292
const makeQuestion = (type: string, description?: string, options?: any[]) =>
({ type, description, options } as any);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about using Question type here?
Something like

const makeQuestion = (
    type: string,
    description?: string,
    options?: { id: number | string; value: string; description?: string }[]
  ) => ({ type, description, options } as unknown as Question);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dmitrycnstrc dmitrycnstrc requested a review from Copilot May 28, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 11 out of 11 changed files in this pull request and generated 5 comments.

Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts
Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts
Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts Outdated
Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts Outdated
Comment thread src/hooks/usePropsGetters/useSelectInputProps.ts

@Alexey-Pavlov Alexey-Pavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you!

@esezen esezen merged commit 9dff8c8 into Constructor-io:main Jun 1, 2026
9 of 10 checks passed
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.

4 participants