Skip to content

Fixed issue #342 -- Add hide/unhide button for passwords in change password#352

Open
Alien501 wants to merge 5 commits intodjangoindia:mainfrom
Alien501:issue_342
Open

Fixed issue #342 -- Add hide/unhide button for passwords in change password#352
Alien501 wants to merge 5 commits intodjangoindia:mainfrom
Alien501:issue_342

Conversation

@Alien501
Copy link
Copy Markdown

@Alien501 Alien501 commented Apr 3, 2025

Closes #342

Added an enhancement feature in profile page. Added toggle button to show/hide password.

Changes

  • Added toggle feature in Profile page, for change password section.

Type of change

  • [ x] Feature update

Demo

image

Summary by CodeRabbit

  • New Features
    • Change Password form now lets you show or hide the New Password and Confirm Password fields via an eye icon toggle.
    • Passwords are hidden by default; tap the icon to reveal or conceal text as needed.
    • Dynamic eye/eye-slash icons provide clear feedback on visibility state.
    • Input layout refined to include inline toggle buttons, improving usability and reducing entry errors, especially on mobile.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to Django India! 🎉🇮🇳

We're so happy to see you contribute. Your efforts mean a lot to us and we're excited to have you on this journey.

Before we proceed, please take a moment to review our contribution guide. It's packed with all the information you need to make your contribution seamless.

If you're fixing an issue from the Django India issue tracker, remember to get it assigned to you before you acutally start working on it.

If you ever need help or just want to chat, the Django India discord server is always open. We're here for you!

And while you're here, don't forget to ⭐ star our repo to show your support! It helps the community grow.

Thank you for being a part of Django India. Together, let's make an amazing community! 🚀

Copy link
Copy Markdown
Member

@DevilsAutumn DevilsAutumn left a comment

Choose a reason for hiding this comment

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

Thanks for this patch @Alien501 ! Left comments.

A small suggestion: Please get the issue assigned to you before you start working on it. This prevents rework if multiple people are working on the same issue.

Comment on lines +64 to +69

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please revert

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What do you want me to do here exactly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the space was removed in this line. add that space back so that there if no diff in this line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see its still there

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry, could you check now

Copy link
Copy Markdown
Member

@DevilsAutumn DevilsAutumn left a comment

Choose a reason for hiding this comment

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

Looks good to me, Thanks ! @Alien501

@DevilsAutumn DevilsAutumn changed the title Fixed issue #342 -- Add hide/unhide button for passwords in change pa… Fixed issue #342 -- Add hide/unhide button for passwords in change password May 11, 2025
</FormControl>
<Button
className='absolute right-1 top-1/2 -translate-y-1/4 bg-transparent text-foreground hover:bg-transparent mt-2 w-max'
onClick={(e) => {e.preventDefault(); togglePasswordVisibility(field.name)}}>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we really need to preventDefault here ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah ig, since it is nested inside a form there is chance of it to be considered to be a submit action when clicked on it. Can be replaced with type="button"

@yanurag-dev
Copy link
Copy Markdown
Contributor

@CodeRabbit fullreview

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 28, 2025

@Yadavanurag13 I'll conduct a full review of this PR that adds the hide/unhide toggle functionality for password fields in the change password section.

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 28, 2025

Walkthrough

Adds password visibility toggles to the ChangePasswordForm component by introducing local state, toggle handler, eye/eye-slash icons, and switching input types between password and text for new and confirm password fields.

Changes

Cohort / File(s) Summary
Password visibility toggle
frontend/src/containers/Users/ChangePasswordForm.tsx
Added showPassword state and togglePasswordVisibility(field) handler; imported FaEye/FaEyeSlash; converted password inputs to conditional type based on visibility; added adjacent buttons with icons; updated container classes for positioning.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Form as ChangePasswordForm
  participant UI as Password Inputs

  User->>Form: Click "eye" on New/Confirm field
  activate Form
  Note right of Form: togglePasswordVisibility(field)
  Form->>Form: Flip showPassword[field] boolean
  deactivate Form
  Form->>UI: Re-render with input type = text/password
  UI-->>User: Field text visibility updates (eye/eye-slash icon toggles)

  %% Error/edge cases can be visual (no backend calls involved)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A twitch of whiskers, a click of the eye,
Now passwords peek, then scurry and hide.
I tap-tap-tap with paws so spry,
See the stars, then mask the sky.
Hoppy toggles guard my pride—
Peek-a-boo security, carrot-certified! 🥕👀

Pre-merge checks and finishing touches

✅ 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 clearly describes the primary change by stating that it adds a hide/unhide button for password fields in the change password form and references the relevant issue number, making it immediately clear to reviewers what the pull request accomplishes.
Linked Issues Check ✅ Passed The pull request fully implements the objectives of issue #342 by introducing local visibility state for both the new and confirm password fields, adding a toggle function that flips visibility, rendering FaEye and FaEyeSlash icons, and conditionally switching the input types, thereby satisfying all coding requirements of the linked issue.
Out of Scope Changes Check ✅ Passed All modifications are confined to the ChangePasswordForm.tsx component and exclusively pertain to adding the show/hide password toggle functionality, with no unrelated or extraneous changes detected.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b2a990 and 98f8864.

📒 Files selected for processing (1)
  • frontend/src/containers/Users/ChangePasswordForm.tsx (4 hunks)

Comment on lines +125 to +136
<Button
className='absolute right-1 top-1/2 -translate-y-1/4 bg-transparent text-foreground hover:bg-transparent mt-2 w-max'
onClick={(e) => {e.preventDefault(); togglePasswordVisibility(field.name)}}>
{field.name === 'newPassword'
? showPassword.newPassword
? <FaEyeSlash size={18} />
: <FaEye size={18} />
: showPassword.confirmPassword
? <FaEyeSlash size={18} />
: <FaEye size={18} />
}
</Button>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add accessible name/state to the visibility toggle button.

The icon-only button currently has no accessible name or pressed state, so screen-reader users will encounter an unlabeled control and cannot tell whether the password is visible. Please surface an accessible label that reflects the action (show/hide) and expose the toggle state via aria-pressed. Once you make it a plain type="button", the extra preventDefault handler is no longer necessary.

Apply this diff to address the issue:

-                                            <Button
-                                                className='absolute right-1 top-1/2 -translate-y-1/4 bg-transparent text-foreground hover:bg-transparent mt-2 w-max'
-                                                onClick={(e) => {e.preventDefault(); togglePasswordVisibility(field.name)}}>
+                                            <Button
+                                                type="button"
+                                                aria-label={
+                                                    field.name === 'newPassword'
+                                                        ? (showPassword.newPassword ? 'Hide new password' : 'Show new password')
+                                                        : (showPassword.confirmPassword ? 'Hide confirm password' : 'Show confirm password')
+                                                }
+                                                aria-pressed={
+                                                    field.name === 'newPassword'
+                                                        ? showPassword.newPassword
+                                                        : showPassword.confirmPassword
+                                                }
+                                                className='absolute right-1 top-1/2 -translate-y-1/4 bg-transparent text-foreground hover:bg-transparent mt-2 w-max'
+                                                onClick={() => togglePasswordVisibility(field.name)}>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Button
className='absolute right-1 top-1/2 -translate-y-1/4 bg-transparent text-foreground hover:bg-transparent mt-2 w-max'
onClick={(e) => {e.preventDefault(); togglePasswordVisibility(field.name)}}>
{field.name === 'newPassword'
? showPassword.newPassword
? <FaEyeSlash size={18} />
: <FaEye size={18} />
: showPassword.confirmPassword
? <FaEyeSlash size={18} />
: <FaEye size={18} />
}
</Button>
<Button
type="button"
aria-label={
field.name === 'newPassword'
? (showPassword.newPassword ? 'Hide new password' : 'Show new password')
: (showPassword.confirmPassword ? 'Hide confirm password' : 'Show confirm password')
}
aria-pressed={
field.name === 'newPassword'
? showPassword.newPassword
: showPassword.confirmPassword
}
className='absolute right-1 top-1/2 -translate-y-1/4 bg-transparent text-foreground hover:bg-transparent mt-2 w-max'
onClick={() => togglePasswordVisibility(field.name)}>
{field.name === 'newPassword'
? showPassword.newPassword
? <FaEyeSlash size={18} />
: <FaEye size={18} />
: showPassword.confirmPassword
? <FaEyeSlash size={18} />
: <FaEye size={18} />
}
</Button>
🤖 Prompt for AI Agents
In frontend/src/containers/Users/ChangePasswordForm.tsx around lines 125 to 136,
the icon-only visibility toggle button lacks an accessible name and state;
change the Button to type="button", remove the unnecessary e.preventDefault()
call, add a dynamic aria-label that reflects the action ("Show password" or
"Hide password") based on the current visibility for the given field, and set
aria-pressed to a boolean representing whether the password is currently visible
(true when visible, false when hidden) so screen readers receive both label and
toggle state.

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.

[FEATURE] Add hide/unhide button for passwords in change password

4 participants