Skip to content

Add reusable PasswordInput component with visibility toggle#200

Open
jonathangreen wants to merge 1 commit intomainfrom
feature/password-input-component
Open

Add reusable PasswordInput component with visibility toggle#200
jonathangreen wants to merge 1 commit intomainfrom
feature/password-input-component

Conversation

@jonathangreen
Copy link
Member

Description

Add a reusable PasswordInput component that wraps a standard <input> with a show/hide toggle button using the existing VisibleIcon and HiddenIcon SVGs. The component manages its own visibility state internally and forwards all standard input props via React.forwardRef.

Use PasswordInput in DebugAuthentication so admins can reveal the patron password field when needed. Add supporting styles for the toggle button positioned inside the input.

Motivation and Context

Code review feedback on the debug authentication feature requested using type="password" for the password input (already done) and adding a way for users to reveal the password. Since there are multiple password fields in the app (DebugAuthentication, ChangePasswordForm) and more may come, a reusable component avoids duplicating toggle logic.

How Has This Been Tested?

  • npm run test-jest-file tests/jest/components/PasswordInput.test.tsx — 5 tests pass (default type, toggle behavior, aria-labels, prop passthrough, wrapper class)
  • npm run test-jest-file tests/jest/components/DebugAuthentication.test.tsx — 9 existing tests continue to pass
  • Pre-commit hooks (eslint + prettier) pass

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen changed the base branch from main to feature/patron-debug-authentication February 27, 2026 01:50
@jonathangreen jonathangreen force-pushed the feature/password-input-component branch from 7d634da to a03088c Compare February 27, 2026 01:52
@jonathangreen jonathangreen requested a review from a team February 27, 2026 01:53
Base automatically changed from feature/patron-debug-authentication to main February 27, 2026 14:48
Extract a PasswordInput component that wraps a standard input with
a show/hide toggle button using VisibleIcon/HiddenIcon. Use it in
DebugAuthentication to let admins reveal the password when needed.
@jonathangreen jonathangreen force-pushed the feature/password-input-component branch from a03088c to 51b6763 Compare February 27, 2026 14:51
Copy link
Contributor

@tdilauro tdilauro 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! 🙈

One suggestion below.

Comment on lines +106 to +131
.password-input-wrapper {
position: relative;

input {
padding-right: 40px;
}

.password-toggle-btn {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 50%;
right: 6px;
background: none;
border: none;
padding: 4px;
cursor: pointer;
transform: translateY(-50%);

svg {
width: 20px;
height: auto;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion - Since PasswordInput is meant to be reusable, this should stand on its own, too, so that the control will get styled properly when used elsewhere.

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.

2 participants