Text_Input Page – Trim Input to Fix Empty Quiz Bug#573
Text_Input Page – Trim Input to Fix Empty Quiz Bug#573Adilkhan6465 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughText_Input now trims user input and Google Doc URL before validation, prevents saving/dispatch when both are empty, adds an inline error state, stores trimmed text in localStorage and backend dispatch, and clears Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
eduaid_web/src/pages/Text_Input.jsx (1)
186-191: Consider clearing error when user types.The error message persists until the user clicks "Next" again. For better UX, clear the error when the user starts typing in the textarea.
✨ Proposed fix to clear error on input change
<textarea className="absolute inset-0 p-8 pt-6 bg-[`#83b6cc40`] text-lg sm:text-xl rounded-2xl outline-none resize-none h-full overflow-y-auto text-white caret-white" style={{ scrollbarWidth: "none", msOverflowStyle: "none" }} value={text} - onChange={(e) => setText(e.target.value)} + onChange={(e) => { + setText(e.target.value); + if (error) setError(""); + }} />Similarly for the docUrl input at line 218:
- onChange={(e) => setDocUrl(e.target.value)} + onChange={(e) => { + setDocUrl(e.target.value); + if (error) setError(""); + }}Also applies to: 195-196
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@eduaid_web/src/pages/Text_Input.jsx` around lines 186 - 191, The textarea onChange currently only updates text via setText but does not clear the validation error, so update the onChange handlers for the textarea (the element using value={text} and onChange={(e) => setText(e.target.value)}) to also clear the error state (e.g., call setError('') or setError(null) after setText) and apply the same change to the docUrl input's onChange handler to clear the same error state when the user types; ensure you reference and use the existing error state setter (setError) used elsewhere in this component.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@eduaid_web/src/pages/Text_Input.jsx`:
- Around line 54-64: Validation currently uses trimmedText but the component
still saves and sends the original text and doesn't trim docUrl; change logic so
you create and use trimmedText = text.trim() and trimmedDocUrl = docUrl?.trim()
(or empty string) for all downstream uses: replace any localStorage save (where
text is stored) and the API payload (where text is sent) to use trimmedText, and
update the validation check to use trimmedDocUrl instead of raw docUrl so
spaces-only URL fails validation; ensure any state/variables that persist or are
sent (e.g., in the submit handler that references text or docUrl) are switched
to these trimmed variables (locations: usages around the save-to-localStorage
call and the API call near the submit function).
---
Nitpick comments:
In `@eduaid_web/src/pages/Text_Input.jsx`:
- Around line 186-191: The textarea onChange currently only updates text via
setText but does not clear the validation error, so update the onChange handlers
for the textarea (the element using value={text} and onChange={(e) =>
setText(e.target.value)}) to also clear the error state (e.g., call setError('')
or setError(null) after setText) and apply the same change to the docUrl input's
onChange handler to clear the same error state when the user types; ensure you
reference and use the existing error state setter (setError) used elsewhere in
this component.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0625fbed-aea6-4600-bd25-74191d1910fa
📒 Files selected for processing (1)
eduaid_web/src/pages/Text_Input.jsx
…mpty quiz generation
|
Closing this PR as the changes have been consolidated into a single unified PR that includes:
Please refer to PR #609 for the complete implementation. |
Description
Addressed Issues:
Fixes #572
Problem:
On the Text_Input page, if a user enters only spaces and clicks Next, the app still attempts to generate a quiz. This causes:
-Unnecessary backend calls
-Potential empty quiz generation
Fix Implemented:
-Trimmed the input before validation using text.trim().
-Added an inline error message when the input is empty:
“Please enter some text to generate the quiz.”
-If input is valid, the app proceeds normally to generate the quiz.
Testing / Screen Recording:
-Entering only spaces → inline error appears, backend call prevented.
-Entering valid text → quiz is generated as expected.
-A short screen recording is attached showing this flow.
Screenshots/Recordings:
TextInput_EmptyVsValidInput.mp4
TextInput_EmptyVsValidation.mp4.mp4
Additional Notes:
-PR focuses only on input validation and UX improvement.
-Compatible with existing file upload and Google Doc input functionality.
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
Checklist
Summary by CodeRabbit