Skip to content

XXXX taking over for Kanishk: Phase 4 - Task Comments Frontend Implementation#4227

Open
kanishkagarwal6101 wants to merge 6 commits intodevelopmentfrom
kanishk_task_comments_frontend
Open

XXXX taking over for Kanishk: Phase 4 - Task Comments Frontend Implementation#4227
kanishkagarwal6101 wants to merge 6 commits intodevelopmentfrom
kanishk_task_comments_frontend

Conversation

@kanishkagarwal6101
Copy link
Copy Markdown
Contributor

Description

Implements Phase 4 - Task Comments Frontend feature for the Education Portal. This PR adds comprehensive comment functionality to the WriteTaskUpload component, allowing students to post comments and educators to view them, with full dark mode support and delete functionality.

Related PRS (if any):

This is a standalone frontend feature. No related backend PRs at this time.

Main changes explained:

  • Create file CommentBox.jsx - Comment input component with validation and character counter
  • Create file CommentList.jsx - Comment display component with delete functionality for own comments
  • Create file Toast.jsx - Toast notification system for success/error feedback
  • Create file useToast.js - Custom hook for managing toast notifications
  • Create file CommentBox.module.css - Styling for comment input with dark mode support
  • Create file CommentList.module.css - Styling for comment list with dark mode support
  • Create file Toast.module.css - Styling for toast notifications
  • Update file WriteTaskUpload.jsx - Integrated comment components with localStorage persistence
  • Update file WriteTaskUpload.module.css - Added comprehensive dark mode styling for entire component

How to test:

  1. Check into current branch: git checkout kanishk_task_comments_frontend
  2. Run npm install to install dependencies
  3. Run the app locally: npm run start:local
  4. Clear site data/cache
  5. Navigate to: http://localhost:3000/educationportal/tasks/upload
  6. Test comment submission:
    • Type a comment in the "Comments/Queries Section"
    • Click "Submit" - should show success toast
    • Comment should appear in the list below
  7. Test validation:
    • Try submitting empty comment - should show inline error
    • Try submitting 1000+ characters - should show character limit error
  8. Test delete functionality:
    • Click the red "×" button on your own comments
    • Should show success toast and remove comment
  9. Test dark mode:
    • Toggle dark mode - all icons, text, and components should be properly styled
    • Comments should persist after page refresh

Screenshots or videos of changes:

  • Comment input with validation and character counter
  • Comment list with delete buttons for own comments
  • Toast notifications for success/error feedback
  • Full dark mode support across all components
  • Responsive design with proper spacing

Note:

  • Comments are persisted using localStorage (task-specific storage)
  • Delete functionality only available for comments posted by current user
  • All components follow the existing design system and dark mode patterns
  • Ready for backend integration - API endpoints can be easily connected when available
  • No breaking changes to existing functionality

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 17, 2025

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit fd779ba
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/693c93f98db26900071a9e03
😎 Deploy Preview https://deploy-preview-4227--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Dec 4, 2025
Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

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

Hi Kanishk,

I have reviewed your PR locally - i only have 2 concerns.

  1. Try submitting 1000+ characters - should show character limit error You mentioned character limit error - it only stops me due to character limit inline and doesn't throw any error - is it supposed to inline as if it not then i do not see any error being displayed.
  2. Delete functionality only available for comments posted by current user - I am able to delete someone else's comment as you can see in the below video. I have left my comments as is and have also tested this using other login's and was able to delete comments left at the end of below video.
    https://github.com/user-attachments/assets/1350b613-4294-451c-85bf-aecd4c7aa329

@SwathiAngadi
Copy link
Copy Markdown
Contributor

Hi Kanishk,

Able to see the comments made in comment section as Student comments. Dark mode is working. However as mentioned in the above review, I am able to delete others comments along with mine. And I don't see any inline error for empty comment and 1000+ character submission.
Saw your code, Error msg is triggered only when Submit button is clicked , but you are disabling the button itself when there is no character hence error logic wont be triggered. Try enabling the Submit button or need to use different logic to show error message.

Screen.Recording.2025-12-08.234000.mp4

- Fix character limit error: Remove maxLength attribute and show inline error when exceeding 1000 characters
- Fix empty comment error: Enable submit button to allow error display on submit
- Fix delete security: Use userId comparison instead of name comparison to prevent unauthorized deletions
- Add visual feedback: Character count turns red when exceeding limit
- Add server-side validation: Double-check userId in handleDeleteComment for additional security
- Add PropTypes validation to all components (CommentBox, CommentList, Toast, Icon, BellIcon)
- Improve error handling with development-mode logging
- Fix CSS contrast issues (improved text colors for better accessibility)
- Remove duplicate CSS selectors (:root and .headerDark)
- Extract validation logic to reduce cognitive complexity
- Improve code maintainability and reliability
… complexity

- Fix contrast issue in CommentBox.module.css by using darker blue (#2563eb) for better WCAG compliance
- Reduce cognitive complexity in WriteTaskUpload.jsx by extracting render helpers and event handlers
- Extract functions: renderSidebar, renderHeader, renderFormSection, renderHistorySection, renderProgressPane, renderFormGrid
- Extract event handlers: handleCommentChange, handleLinkUrlChange, handleShowLink
- Extract data management: loadCommentsFromStorage, getDefaultComments, saveCommentsToStorage, createNewComment, formatItemTime
- Extract validation: validateDeletePermission
- Change color from 'white' to '#ffffff' for better specificity
- Use darker gradient colors (#2563eb, #7c3aed) for better contrast
- Update dark mode gradient to even darker shades (#1e40af, #6d28d9)
…eration

- Replace Date.now() + Math.random() with crypto.randomUUID() in useToast hook
- Use cryptographically secure random number generator to satisfy SonarQube security hotspot
- crypto.randomUUID() is available in all modern browsers and provides proper UUIDs
@sonarqubecloud
Copy link
Copy Markdown

@kanishkagarwal6101
Copy link
Copy Markdown
Contributor Author

Hello All, I have made the changes as requested please I re-request review from all. Your feedback is very helpful.

Copy link
Copy Markdown

@debadyuti23 debadyuti23 left a comment

Choose a reason for hiding this comment

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

Hi @kanishkagarwal6101 I have verified the changes, it works correctly. Couple of observations which I can see:

  1. The submit button and pie chart got removed when I submitted a very long comment.
  2. In dark mode, various functionalities like the progress bar, pie chart does not adjust with proper color.

Test video 1: https://drive.google.com/file/d/1SqTdH3_agCdtP8EZY3ffmN9Uyw_LyCWu/view?usp=sharing

Test video 2: https://github.com/user-attachments/assets/6299a3e1-8eba-48d5-89f3-fa0df0747e78

Since these changes are not related to PR, I have approved it. However please be mindful about these issues in future.

Copy link
Copy Markdown

@rohanrastogi311 rohanrastogi311 left a comment

Choose a reason for hiding this comment

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

Functionality works well, well done. Need to do dark mode fixes. Lot's of white boxes still showing, check image below.

PR 4227 Screenshot PR 4227 Screenshot 2 PR 4227 Screenshot 3

Copy link
Copy Markdown
Contributor

@ShreyaMP1999 ShreyaMP1999 left a comment

Choose a reason for hiding this comment

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

Tested the current branch locally following the provided steps. Comment submission, validation (empty and character limit), delete functionality, dark mode styling, and comment persistence after refresh are all working as expected. No issues found.

Screen.Recording.2026-01-03.at.4.07.44.PM.mov

Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

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

Hi Kanishk,

I have re-reviewed your PR and thanks for implementing the change i had suggested. All requirements works as expected
Screenshot 2026-01-06 at 8 12 56 PM
Screenshot 2026-01-06 at 8 13 17 PM
Screenshot 2026-01-06 at 8 14 00 PM
Screenshot 2026-01-06 at 8 14 31 PM
Screenshot 2026-01-06 at 8 14 59 PM

Copy link
Copy Markdown
Contributor

@Shravan-neelamsetty Shravan-neelamsetty left a comment

Choose a reason for hiding this comment

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

Hi Kanishk, I tested this PR locally by navigating to /educationportal/tasks/upload and verified the comment functionality. Comment submission works correctly with proper validation for empty comments and character limits. The character counter displays accurately, and comments persist after page refresh as expected. The delete functionality correctly restricts deletion to only the current user's comments. However, I noticed dark mode issues: there are several white boxes visible in dark mode, and some elements like the progress bar and pie chart don't adjust with proper dark mode colors.

@
Screenshot 2026-01-08 at 6 05 48 PM
Screenshot 2026-01-08 at 6 06 02 PM
Screenshot 2026-01-08 at 6 06 31 PM

Copy link
Copy Markdown

@Vikas-8055 Vikas-8055 left a comment

Choose a reason for hiding this comment

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

Hi Kanishk,

I have reviewed your PR locally and tested the comment functionality. The main features are working correctly - comment submission with character counter, validation for empty comments and 1000+ character limit, delete functionality for own comments, and comment persistence after refresh all work as expected. I tested in both light and dark modes, and the Comments/Queries Section displays properly with readable text and buttons in both modes.

I noticed some white boxes visible in dark mode (Unit 1 selection button, Choose Trades button, and file upload area), but as other reviewers mentioned, these appear to be part of the existing page layout and outside the scope of this PR which specifically focuses on the comment functionality. The comment components themselves have proper dark mode styling.

Screenshot 2026-01-08 at 6 22 32 PM Screenshot 2026-01-08 at 6 22 45 PM

Copy link
Copy Markdown

@Ganesh112001 Ganesh112001 left a comment

Choose a reason for hiding this comment

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

Hi Kanishk, I tested PR #4227 and verified that the Task Comments feature works perfectly. After navigating to /educationportal/tasks/upload, I confirmed that students can post comments with proper validation and character counter, delete their own comments with the red × button, and receive success/error toast notifications. Dark mode is fully supported with excellent contrast across all components. Comments persist correctly using localStorage after page refresh. No console errors observed. Everything functions perfectly and is ready for merge!

Screenshot 2026-01-18 at 1 20 26 AM Screenshot 2026-01-18 at 1 20 46 AM

Copy link
Copy Markdown

@Vikas-8055 Vikas-8055 left a comment

Choose a reason for hiding this comment

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

Hi Kanishk,

I reviewed your PR locally and all core features work great! Comment submission works smoothly with the character counter, empty comment validation shows inline errors, and the 1000+ character limit displays the proper error message. Delete functionality works correctly I can only delete my own comments and the success toast appears as expected. Comments persist after page refresh.

Regarding @rohanrastogi311's dark mode feedback the Progress Bar and Drag & Drop areas are pre-existing components outside this PR's scope. A separate PR should be raised to address those dark mode issues. This PR focuses on the Task Comments feature, and the Comments/Queries Section is properly styled in both light and dark mode.

Screenshot 2026-01-30 at 9 19 08 PM Screenshot 2026-01-30 at 9 18 55 PM Screenshot 2026-01-30 at 9 18 47 PM

Copy link
Copy Markdown
Contributor

@roshini1212 roshini1212 left a comment

Choose a reason for hiding this comment

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

Tested the kanishk_task_comments_frontend branch locally and all functionality works perfectly at "/educationportal/tasks/upload". Comment submission displays success toasts and lists correctly, validation properly blocks empty submissions and 1000+ character inputs with clear inline errors, delete removes own comments with confirmation toasts and light mode styling is fully responsive across all components.
The dark mode has some white boxes which felt off. But the basic functionalities according to the PR are working properly.

Image Image Image

@maithili20
Copy link
Copy Markdown
Contributor

Hi @kanishkagarwal6101
I reviewed your PR locally and everything works fine in both dark and light modes. The 1000 character limit and empty error are shown as well. The toast messages seem to work too. I can delete my commnet but I am able to delete comments from others as well.

Screenshot 2026-02-09 at 6 53 19 PM Screenshot 2026-02-09 at 6 53 50 PM Screenshot 2026-02-09 at 6 54 14 PM Screenshot 2026-02-09 at 6 55 39 PM

Copy link
Copy Markdown

@naznin07 naznin07 left a comment

Choose a reason for hiding this comment

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

Controlled textarea with validation.
PR #4227

Copy link
Copy Markdown
Contributor

@ManojPuttaswamy ManojPuttaswamy left a comment

Choose a reason for hiding this comment

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

Tested all functionality and everything works as expected. One minor fix needed — the submit button should be disabled when the comment exceeds 1000 characters. This can be done by updating the disabled prop on the button.

disabled={disabled || comment.length > 1000}

<button
type="submit"
className={`${styles.submitButton} ${darkMode ? styles.submitButtonDark : ''}`}
disabled={disabled}
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 button is only disabled when the disabled prop is true, but not when the character limit is exceeded. A user can still submit while the error is showing:

Copy link
Copy Markdown
Contributor

@saisandeepkoritala saisandeepkoritala left a comment

Choose a reason for hiding this comment

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

Hi Kaniskh,

I ran your PR locally and all seems good in light and dark mode, everything works as intended. But i was able to delete other user comment.

Image

@SharadhaKasiviswanathan
Copy link
Copy Markdown
Contributor

Tested this locally and reproduced the issue: when 'currentUserId' is missing, clicking Submit shows the error toast 'Unable to identify user. Please refresh the page and try again', but the text area is still cleared, so the user loses their draft even though nothing was posted. This comes from CommentBox clearing its local state immediately after calling onSubmit(), while handleCommentSubmit() in 'WriteTaskUpload' can early return on failure. Can the flow be updated so that the input is cleared only after the parent confirms a successful submit?
Also, another issue is that a user is able to delete all the other comments as well (attached in the last screenshot).
image
image
Screenshot 2026-03-29 at 5 59 48 AM

@one-community one-community changed the title Kanishk: Phase 4 - Task Comments Frontend Implementation Vikas taking over for Kanishk: Phase 4 - Task Comments Frontend Implementation Apr 5, 2026
Copy link
Copy Markdown

@rajanidi1999 rajanidi1999 left a comment

Choose a reason for hiding this comment

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

Overall looks good. The components are well-structured and reusable, and the feature implementation is solid. Just a few minor improvements to consider: remove unnecessary Promise.resolve() in async functions, standardize API response/error shapes for consistency, and disable the submit button in CommentBox when validation fails (e.g., character limit exceeded). These are non-blocking and can be addressed in follow-ups.

Copy link
Copy Markdown

@rajanidi1999 rajanidi1999 left a comment

Choose a reason for hiding this comment

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

Hi,
i have tested your PR locally and its working well.

Image Image

Copy link
Copy Markdown

@rithika-paii rithika-paii left a comment

Choose a reason for hiding this comment

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

Hi Kanishk,

I reviewed this PR and tested the Task Comments functionality on the upload page in both light and dark modes. The overall feature works as expected, but I found one issue:

Comment deletion permission issue: Currently, it is possible to delete comments posted by other users. The delete option should be restricted so that users can only delete their own comments, as mentioned in the PR description.

PR.4227.mov

Copy link
Copy Markdown

@saurabhdipte saurabhdipte left a comment

Choose a reason for hiding this comment

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

Hi Vikas,

I tested the changes locally. I’m able to submit a comment and delete it successfully. However, I also noticed that I’m able to delete other students’ comments, which might need to be restricted.

The validation for empty comments is working as expected. For the 1000+ character limit, I’m able to enter more than 1000 characters in the text box, but submission is blocked. It might be better to restrict input beyond 1000 characters at the typing level itself.

In dark mode, there are a few contrast-related issues, particularly with some text boxes, which may need adjustment.

Image

Copy link
Copy Markdown

@kunchalasireesha kunchalasireesha left a comment

Choose a reason for hiding this comment

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

Hi Vikas, it looks like this PR currently has merge conflicts with the base branch. Could you please rebase or merge the latest changes from development into your branch and resolve the conflicts? Once the build passes, I’ll finish the review.

@one-community one-community added Needs New Developer This is a PR that is partially developed but needs someone new to take it over and finish it. do not review Do not review or look at code without full context and removed High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible labels May 3, 2026
@one-community one-community changed the title Vikas taking over for Kanishk: Phase 4 - Task Comments Frontend Implementation XXXX taking over for Kanishk: Phase 4 - Task Comments Frontend Implementation May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not review Do not review or look at code without full context Needs New Developer This is a PR that is partially developed but needs someone new to take it over and finish it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.