Skip to content

Text_Input Page – Trim Input to Fix Empty Quiz Bug#573

Closed
Adilkhan6465 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Adilkhan6465:bug/text-input-validation
Closed

Text_Input Page – Trim Input to Fix Empty Quiz Bug#573
Adilkhan6465 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Adilkhan6465:bug/text-input-validation

Conversation

@Adilkhan6465
Copy link
Copy Markdown
Contributor

@Adilkhan6465 Adilkhan6465 commented Mar 14, 2026

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:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • Bug Fixes
    • Input is now trimmed automatically before saving or sending.
    • Submitting empty text (without a document link) shows an inline error and is prevented.
    • Google Doc links are validated using trimmed input; successful imports clear the link field.
    • Local save and backend submissions use the trimmed text to avoid storing leading/trailing whitespace.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a138d74-e8a3-4582-bee9-cf5b2fb62c6f

📥 Commits

Reviewing files that changed from the base of the PR and between cdd0339 and 5eb3dd3.

📒 Files selected for processing (1)
  • eduaid_web/src/pages/Text_Input.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • eduaid_web/src/pages/Text_Input.jsx

📝 Walkthrough

Walkthrough

Text_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 docUrl after successful Google Doc handling.

Changes

Cohort / File(s) Summary
Input Validation & Error Handling
eduaid_web/src/pages/Text_Input.jsx
Added error state and inline error UI. Trimmed text and docUrl before validation and saving. Abort save/dispatch when both trimmed values are empty. Use trimmed values for localStorage and backend dispatch. Adjusted Google Doc flow to use and clear trimmedDocUrl on success.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰
I nibbled spaces, found them thin,
Trimmed the fluff and let truth in.
No empty quizzes hopping through,
Cleaned inputs, stored the true-blue.
A little hare, a tidy cue.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: trimming input on the Text_Input page to fix the empty quiz bug, which aligns with the primary objective.
Linked Issues check ✅ Passed The code changes fully implement all requirements from issue #572: trimming input before validation, preventing quiz generation for empty trimmed input, and surfacing validation errors to the user.
Out of Scope Changes check ✅ Passed All changes are directly related to input validation and trimming for the Text_Input page as specified in issue #572; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc3bf1a and cdd0339.

📒 Files selected for processing (1)
  • eduaid_web/src/pages/Text_Input.jsx

Comment thread eduaid_web/src/pages/Text_Input.jsx
@SxBxcoder SxBxcoder mentioned this pull request Mar 17, 2026
@Adilkhan6465
Copy link
Copy Markdown
Contributor Author

Closing this PR as the changes have been consolidated into a single unified PR that includes:

  • Input validation improvements
  • Google Doc URL handling
  • Proper error state management

Please refer to PR #609 for the complete implementation.

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.

[BUG]: Text_Input Page – Trim Input to Fix Empty Quiz Bug

1 participant