Skip to content
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
30 changes: 24 additions & 6 deletions src/components/workspace-canvas/QuizContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ export function QuizContent({ item, onUpdateData, isScrollLocked = false }: Quiz
}
};

// Arrow navigation - only moves between questions, never shows results
const handleArrowNext = () => {
if (currentIndex < totalQuestions - 1) {
const nextIndex = currentIndex + 1;
setCurrentIndex(nextIndex);
persistSession({ currentIndex: nextIndex });
}
};
Comment on lines +182 to +188

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.

The new handleArrowNext duplicates the logic from handleNext (lines 170-174). Could be refactored to share code:

const handleArrowNext = () => {
  if (currentIndex < totalQuestions - 1) {
    const nextIndex = currentIndex + 1;
    setCurrentIndex(nextIndex);
    persistSession({ currentIndex: nextIndex });
  }
};

vs the same logic in handleNext lines 170-174.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/workspace-canvas/QuizContent.tsx
Line: 182:188

Comment:
The new `handleArrowNext` duplicates the logic from `handleNext` (lines 170-174). Could be refactored to share code:

```
const handleArrowNext = () => {
  if (currentIndex < totalQuestions - 1) {
    const nextIndex = currentIndex + 1;
    setCurrentIndex(nextIndex);
    persistSession({ currentIndex: nextIndex });
  }
};
```
vs the same logic in `handleNext` lines 170-174.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.


const handlePrevious = () => {
if (currentIndex > 0) {
const prevIndex = currentIndex - 1;
Expand Down Expand Up @@ -464,9 +473,10 @@ export function QuizContent({ item, onUpdateData, isScrollLocked = false }: Quiz
<button
onMouseDown={preventFocusSteal}
onClick={handleRestart}
className="flex items-center justify-center w-8 h-8 rounded-lg text-sm text-white/40 hover:text-white hover:bg-white/10 transition-colors cursor-pointer"
className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm text-white/40 hover:text-white hover:bg-white/10 transition-colors cursor-pointer"
>
<RotateCcw className="w-4 h-4 rotate-180" />
<span>Restart</span>
</button>
</div>

Expand All @@ -490,11 +500,11 @@ export function QuizContent({ item, onUpdateData, isScrollLocked = false }: Quiz
</span>
<button
onMouseDown={preventFocusSteal}
onClick={isSubmitted ? handleNext : undefined}
disabled={!isSubmitted}
onClick={handleArrowNext}
disabled={currentIndex >= totalQuestions - 1}
className={cn(
"flex items-center justify-center w-8 h-8 rounded-lg text-sm transition-colors cursor-pointer",
!isSubmitted
currentIndex >= totalQuestions - 1
? "text-white/30 cursor-not-allowed"
: "text-white/70 hover:text-white hover:bg-white/10"
)}
Expand All @@ -503,9 +513,9 @@ export function QuizContent({ item, onUpdateData, isScrollLocked = false }: Quiz
</button>
</div>

{/* Right: Check */}
{/* Right: Check/Next Button */}
<div className="flex-1 flex items-center justify-end">
{!isSubmitted && (
{!isSubmitted ? (
<button
onMouseDown={preventFocusSteal}
onClick={handleSubmit}
Expand All @@ -519,6 +529,14 @@ export function QuizContent({ item, onUpdateData, isScrollLocked = false }: Quiz
>
Check
</button>
) : (
<button
onMouseDown={preventFocusSteal}
onClick={handleNext}
className="px-4 py-2 rounded-lg text-sm font-medium transition-colors cursor-pointer bg-blue-500 hover:bg-blue-600 text-white"
>
{currentIndex < totalQuestions - 1 ? "Next" : "Finish"}
</button>
)}
</div>
</div>
Expand Down