Skip to content

Mask passwords set on TextField, and keep input text clear of its trailing icons - #240

Open
deebov wants to merge 1 commit into
mainfrom
fix/input-field-type-and-trailing-padding
Open

deebov wants to merge 1 commit into
mainfrom
fix/input-field-type-and-trailing-padding

Conversation

@deebov

@deebov deebov commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Description

Three fixes to InputBase in components/base/input/input.tsx.

The type set on the field is no longer dropped. InputBase defaulted type to "text" and passed it on explicitly, which overrode the type set on the field around it. This rendered the password as readable text, with no visibility toggle:

<TextField type="password">
    <Label>Password</Label>
    <InputBase />
</TextField>

type="email" and the other types were dropped the same way. InputBase now takes the field's type when it has none of its own. Its own type still wins, and the default is still "text".

Long text no longer runs underneath the controls at the end of the input.

  • The password toggle had no padding reserved for it, at any size.
  • The invalid icon had none when the invalid state came from the field rather than the isInvalid prop of InputBase, which is the case for <Input isInvalid> without a tooltip. The icon is shown with CSS (group-invalid/input), so its padding is now applied by the same state and the two cannot drift apart.

The password toggle reports its state. It is labelled "Show password" and sets aria-pressed, so assistive technology can tell whether the password is shown. Before, it was announced as "Toggle password visibility" in both states.

Two things to be aware of:

  • Code that looks the toggle up by the old aria-label, "Toggle password visibility", needs the new one.
  • InputBase inside a React Aria SearchField now renders type="search" (dropdown-search-simple and dropdown-search-advanced). globals.css already hides the native clear button, and the dropdown renders pixel-identical before and after in Chromium.

No new props or dependencies.

Related issues

Related to #228, which reports the password text overlap.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • Accessibility improvement

Testing

  • bun run test checks pass (type-check, ESLint, Prettier).
  • Browser behaviour tests in Chromium (Storybook test-runner), which fail on main and pass with this change:
    • InputBase keeps the type of its field (password, email, search), its own type wins, and the default is text.
    • The toggle's aria-pressed follows the password's visibility.
    • At sm, md and lg, the input's text area ends before the password toggle (hidden and revealed) and before the invalid icon, whether the invalid state comes from Input, TextField or InputBase.
  • Not tested in Safari or Firefox.

Manual testing steps

  1. Render <TextField type="password"><Label>Password</Label><InputBase /></TextField> and type into it. The value is masked and the eye toggle is shown.
  2. Render <Input type="password" defaultValue="a-very-long-password-that-does-not-fit" /> in a narrow container and press the toggle. The text stops before the icon.
  3. Render <Input isInvalid defaultValue="a-very-long-value-that-does-not-fit" /> in a narrow container. The text stops before the error icon.

…iling icons

InputBase defaulted its type to "text" and passed it on explicitly, which
overrode the type set on the field around it. `<TextField type="password">`
with a plain `<InputBase />` rendered the password as readable text with no
visibility toggle, and `type="email"` was dropped the same way. InputBase now
takes the field's type when it has none of its own.

Long text also ran underneath two of the controls at the end of the input:

- The password toggle, which had no padding reserved for it.
- The invalid icon, when the invalid state came from the field rather than
  the `isInvalid` prop of InputBase, as it does for `<Input isInvalid>`. The
  icon is shown with CSS, so its padding is now applied by the same state.

The password toggle is labelled "Show password" and reports `aria-pressed`,
so assistive technology can tell whether the password is shown.
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.

1 participant