Repository navigation
feat(PasswordInput): add a password field with a show/hide toggle - #173
Conversation
PasswordInput is a Form.Item control on Astryx's TextInput, with TextInput's props minus type, hasSpellCheck, hasAutoCorrect and autoCapitalize. A ghost icon button sits inside the field's trailing edge in the secondary text colour; the control reserves its room so a long password never runs under it. The toggle keeps focus in the field on press, stops an Enter keydown from reaching the form, and is named from uic.PasswordInput.showPassword / hidePassword (overridable, translated in every locale). Spellcheck, autocorrect and autocapitalize are off, and Edge's ::-ms-reveal is hidden. The reveal state is uncontrolled (defaultIsRevealed) or controlled (isRevealed, onRevealedChange). A disabled field is masked with its toggle disabled; an uncontrolled one resets to masked during render on the change, not in an effect.
PR Analysis Report📚 Storybook PreviewGitHub Pages may take up to a minute to hydrate after the deploy. 🧩 Changed Components
22 other changed file(s) in
|
|
Preview published under the pnpm add @lablup/ui-common@0.2.0-alpha.21.pr-173-20261124004145-eabfc7e75
pnpm add -D @lablup/ui-common-cli@0.2.0-alpha.21.pr-173-20261124004145-eabfc7e75In backend.ai-webui: |
|
Consumer: lablup/backend.ai-webui#11382 uses |
agatha197
left a comment
There was a problem hiding this comment.
Ready-gate agent review — 10 findings — 7 Important, 3 Nit, 0 Pre-existing. The summary comment on this PR lists every finding and its outcome.
|
2 findings — 2 Important, 0 Nit, 0 Pre-existing Round 2 —
|
| # | Tag | File:line | Finding | Outcome |
|---|---|---|---|---|
| 1 | Important | src/components/PasswordInput/PasswordInput.tsx:135 |
setInput is a useCallback with empty deps that reads the caller's ref only when the input first attaches, so a caller ref that changes after mount is never set and the old one keeps pointing at the input. |
fixed 37b1905 |
| 2 | Important | src/components/PasswordInput/PasswordInput.tsx:141 |
Removing the value attribute also clears the input's default value, so a native form reset blanks the field on screen without a change event, leaving React state and the submit handler with the old password. |
fixed 37b1905 |
Security review: not re-run (round 2)
Posted inline: 2 · already inline from this round: 0 · table only (outside the diff): 0 · repeats of an earlier round dropped: 0 · Nits over the cap of 3 dropped: 0 · not posted (no file:line, or style-only): 0
Round 1 — 3182bc6
| # | Tag | File:line | Finding | Outcome |
|---|---|---|---|---|
| 1 | Important | src/components/PasswordInput/PasswordInput.css:9 |
The new .uic-password-input root is the flex item a parent row sizes, but it has no min-width: 0, which brings back the overflow Astryx fixed by putting minWidth: 0 on the Field root. |
fixed 63b8e5b |
| 2 | Nit | src/components/PasswordInput/PasswordInput.css:24 |
The toggle is always IconButton size="sm" (28px) with geometry fixed to --size-element-sm, whatever the field's size or SizeContext is. |
fixed 63b8e5b |
| 3 | Important | src/components/PasswordInput/PasswordInput.css:32 |
Form.Item's hasFeedback glyph sits absolutely at inset-inline-end: var(--spacing-3) (12px from the end), which falls inside the toggle (4px to 32px from the end), so the success or error glyph is drawn on top of the eye icon. |
fixed 63b8e5b |
| 4 | Important | src/components/PasswordInput/PasswordInput.tsx:98 |
wasDisabled starts at the first render's isDisabled, so a field that mounts disabled never gets re-masked, and with defaultIsRevealed it shows the password once it is enabled. |
fixed 63b8e5b |
| 5 | Important | src/components/PasswordInput/PasswordInput.tsx:101 |
Re-masking on disable changes the reveal state without calling onRevealedChange(false), so a listener's or a controlled parent's state stays true and a controlled field shows the password again when the form is re-enabled. |
fixed 63b8e5b |
| 6 | Important | src/components/PasswordInput/PasswordInput.tsx:120 |
React keeps the input's value attribute equal to the controlled value, so the typed password sits in the DOM as value="..." on every keystroke; antd's Input.Password removes that attribute and this component does not. |
fixed 63b8e5b |
| 7 | Important | src/components/PasswordInput/PasswordInput.tsx:122 |
The field stays type="text" when the form is submitted or the page comes back from bfcache; there is no hide-on-submit or pageshow reset like GOV.UK's password input has. |
fixed 63b8e5b |
| 8 | Important | src/components/PasswordInput/PasswordInput.tsx:126 |
Inside Astryx InputGroup or a horizontal-labels FormLayout, Astryx renders no Field box, so the always-passed containerClassName triggers a dev warning on every use, the layout classes are dropped, and the extra root div breaks the group or grid structure; an InputGroup isDisabled also does not mask the field, because isDisabled reads only field.isDisabled. The root cause is the overlay itself (TextInput has no end slot), which also drives the min-width, feedback-icon and size findings. |
intentional — e0684a9 (rest fixed 63b8e5b; horizontal-labels FormLayout documented as unsupported) |
| 9 | Nit | src/components/PasswordInput/PasswordInput.tsx:149 |
The lucide icons are sized size="1em", which follows the button's label font-size and ignores the icon size the Button provides through IconDefaultSizeProvider and iconBoxSizeStyles; Astryx <Icon icon={Eye}/>, as SelectionLabel and PageHeader use, would follow it. |
not-worth |
| 10 | Nit | src/components/PasswordInput/PasswordInput.tsx:158 |
Only keydown propagation is stopped, so keypress and keyup for Enter on the toggle still reach ancestor handlers; it also blocks document-level keydown listeners, but not native listeners on the form. |
fixed 63b8e5b |
Security review: 1 finding (posted above as Important)
Posted inline: 10 · already inline from this round: 0 · table only (outside the diff): 0 · repeats of an earlier round dropped: 0 · Nits over the cap of 3 dropped: 0 · not posted (no file:line, or style-only): 0
- Put the toggle inside the field's trailing padding, positioned in a root that takes the field's width, instead of a flex row with a negative margin. The control keeps Astryx's border, focus and status styling, so there is no seam, no containerClassName, and it works in an InputGroup. - Size the toggle to fit inside a small field's border. - Move Form.Item's hasFeedback icon to the toggle's start and reserve its room. - Give the root min-width: 0 so it shrinks in a flex row. - A field that mounts disabled starts masked. - Stop Enter keyup and keypress on the toggle as well as keydown. - Keep the password out of the input's value attribute. - Mask again, and report onRevealedChange(false), when the field is disabled, when its form submits and on a back/forward-cache restore.
agatha197
left a comment
There was a problem hiding this comment.
Ready-gate agent review — 2 findings — 2 Important, 0 Nit, 0 Pre-existing. The summary comment on this PR lists every finding and its outcome.
… preview Takes the ready-gate fixes of #173: the toggle sits in the control's trailing padding, the password stays out of the value attribute, and the field re-masks on submit, on bfcache restore and when disabled. BAIPasswordInput's visual baselines move with the new layout. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
…n#173 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Summary
PasswordInput(@lablup/ui-common/PasswordInput, also from the root): a password field forForm.Itemwith a show/hide toggle. Source insrc/components/PasswordInput/. It renders Astryx'sTextInputunder the same contract as ui-common'sTextInputwrapper (useFormControl,useMergedValue,FormControlScope), so the item supplies label, value, status,disabledand the in-item width.TextInput's minustype,hasSpellCheck,hasAutoCorrectandautoCapitalize, which it owns, plusisRevealed/defaultIsRevealed/onRevealedChange(Astryx'sisOpen/defaultIsOpen/onOpenChangenaming) andshowPasswordLabel/hidePasswordLabel.IconButton(lucideEye/EyeOff) inside the field's trailing edge, coloured--color-text-secondary. TextInput has no end slot, so the root is a flex row and a negative margin pulls the toggle back over the control's edge, wherever the field's width puts it (unset, in-item 100%, or an explicitwidth). The control reserves--size-element-smplus padding at its end, so a long password stops short of the button.input::-ms-revealis hidden so Edge shows no second eye.disabledturns on (prev-prop comparison, no effect), so it stays masked after re-enabling: a login form that disables its fields while submitting hides the password.uic.PasswordInput.showPassword/hidePassword, translated in all 20 locale files.exports.customs.json(withsubpath) and regenerated withgen:exports; CLI docastryx/components/PasswordInput.doc.mjs+ stub; README, CONTRIBUTING component table,ui-common.doc.mjs;CHANGELOG.md### Addedunder[Unreleased]. No version bump or codemod (additive).Tests
PasswordInput.test.tsx: toggles type and accessible name both ways and reportsonRevealedChange;defaultIsRevealed; controlledisRevealed; spellcheck/autocorrect/autocapitalize off; mousedown prevented and focus stays in the field; Enter on the toggle does not reach a parent<form>keydown handler while Enter in the field still does; disabling masks, disables the toggle and stays masked after re-enabling; controlled + disabled is masked; value and disabled throughForm.Item/<Form disabled>; label overrides; Korean catalog name; stylesheet contract (reserved padding,::-ms-reveal, secondary colour).formControls.test.tsxtable (label, error, required, disabled, onBlur validation,focusField, in-item width 100%, explicit width).Verification
pnpm run verifypasses (110 test files, 2387 passed / 16 skipped; integration validates with 0 errors, 0 warnings).pnpm run test:visual:docker src/components/PasswordInputpasses with the new baselines.Context
Consumer: lablup/backend.ai-webui#11278. The login form's prototype wrapper (lablup/backend.ai-webui#11280, closed) moved here; lablup/backend.ai-webui#11382 uses this component and is pinned to this PR's preview. Product: Backend.AI WebUI; the WebUI team does the move.
Risk tier: High —
package.jsonSuggested human approvals: 2 (branch protection decides)
Reviewed by fw ready gate at
63b8e5b(round 2)