Skip to content

Conversation

@v-i-s-h-n-u-ps
Copy link
Contributor

No description provided.

@v-i-s-h-n-u-ps v-i-s-h-n-u-ps marked this pull request as ready for review September 28, 2025 10:58
Copilot AI review requested due to automatic review settings September 28, 2025 10:58
Copy link

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

This PR implements a new "jump to question" feature for the quiz component, allowing users to navigate directly to a specific question within the quiz flow.

  • Adds a new jumpToQuestion event handler and supporting types
  • Implements jump functionality that restricts navigation to previously answered questions
  • Updates documentation to correct the quizAnswerChanged event description

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types.ts Adds type definitions for JumpToQuestion functionality and related prop getters
src/stories/Quiz/Hooks/Docs/markdown/EventsDocs.md Corrects documentation for quizAnswerChanged event
src/hooks/useQuizEvents/useQuizResetClick.ts Fixes return type from NextQuestion to ResetQuiz
src/hooks/useQuizEvents/useJumpToQuestion.ts Implements jump to question logic with validation
src/hooks/useQuizEvents/index.ts Integrates jump to question hook into main events
src/hooks/usePropsGetters/useJumpToQuestionButtonProps.ts Provides button props for jump functionality
src/hooks/usePropsGetters/index.ts Exports jump to question button props getter
src/components/CioQuiz/quizLocalReducer.ts Handles jump to question state management and refactors answer input handling
src/components/CioQuiz/quizApiReducer.ts Clears quiz results when jumping to question
src/components/CioQuiz/index.tsx Exposes jump to question props to component
src/components/CioQuiz/context.ts Adds jump to question to context interface
src/components/CioQuiz/actions.ts Defines jump to question action types

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 19 to 22
tabIndex: buttonDisabled ? -1 : 0,
'aria-disabled': buttonDisabled ? 'true' : 'false',
'aria-describedby': buttonDisabled ? 'jump-to-button-help' : '',
type: 'button',
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The return object includes accessibility attributes (tabIndex, aria-disabled, aria-describedby, type) but the JumpToQuestionButtonProps interface only defines className, onClick, and style. Either update the interface to include these properties or remove them from the return object.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@TarekAlQaddy TarekAlQaddy left a comment

Choose a reason for hiding this comment

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

Thank you for making the changes @v-i-s-h-n-u-ps . I’ve left a few comments for your review. Would it also be possible to include tests for the new hooks? It would be great if the new hook could be added to the hooks documentation as well.

@v-i-s-h-n-u-ps
Copy link
Contributor Author

Tests and documentations

e835cc7

@TarekAlQaddy
Copy link
Contributor

@v-i-s-h-n-u-ps Thanks for working on the comments!

I tested the logic of jumping back to a question and found 2 issues:

  • The logic jumps back to the specified question ID + 1. Example: if question ID is passed as 2 it will jump to question 3 instead
  • On the results page, clicking the jump button keeps you on the results page.
    This happens because isQuizCompleted remains true in the session storage. As a result, skipToResults in useSessionStorageStats.ts immediately applies the “skip to results” logic, keeping you stuck on the results page.
    this is a bit tricky as skipToResults is calculated based on quizData which is directly retrieved from the session storage and can momentarily go out of sync with the quiz's local state in React.

Here's a proposed solution for these 2 issues, could you please review them and apply the changes here in the PR if all is good

@v-i-s-h-n-u-ps
Copy link
Contributor Author

Thank you for the review and finding that issue. I also added some tests to confirm the behaviour.
e62ca24

currentQuestionData?.type === QuestionTypes.SingleFilterValue) &&
singleSelectClicked.current
singleSelectClicked.current &&
nextQuestionOnSingleSelect
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify what's the use case of this additional option? Since it's a single select question it should move forward when a single value has been selected. Why should we give the option of stopping that logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an ask from one of our customer. And I thought it made sense since we would not want accidental clicks to go to next question as soon as you select an option.

@HHHindawy
Copy link
Contributor

Merged in #254

@HHHindawy HHHindawy closed this Oct 9, 2025
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.

3 participants