Skip to content

Commit ea69a61

Browse files
Fix: Add validation and debugging for question navigation
- Check if questions are loaded before navigation - Add console logging for debugging - Validate input before attempting to navigate - Show alert if questions still loading
1 parent 371aa8c commit ea69a61

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/js/editor.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,22 @@ function gotoQuestion() {
369369
const input = document.getElementById('question-input');
370370
const questionNum = parseInt(input.value);
371371

372+
console.log('Goto question:', questionNum, 'Questions loaded:', Object.keys(questionsData).length); // Debug log
373+
374+
if (!questionNum || isNaN(questionNum)) {
375+
// No valid input
376+
return;
377+
}
378+
372379
if (questionNum >= 1 && questionNum <= 1000) {
380+
// Check if questions are loaded
381+
if (Object.keys(questionsData).length === 0) {
382+
alert('Questions are still loading... Please wait a moment and try again.');
383+
return;
384+
}
385+
373386
loadQuestion(questionNum);
374-
input.value = ''; // Clear input
387+
input.value = ''; // Clear input after loading
375388
} else {
376389
alert('Please enter a question number between 1 and 1000');
377390
}

0 commit comments

Comments
 (0)