#4157·primitives

[PasswordToggleField] Controlled `visible` doesn't reset on form submit/reset with React 19.2.x

Author: maricastrocCreated Sep 29, 2026Updated Sep 29, 2026

Bug report

Current Behavior

With a controlled PasswordToggleField (visible + onVisibilityChange) inside a form on React 19.2.x, the password stays visible after the user reveals it and then submits or resets the form (form.reset()). The input stays type="text" and onVisibilityChange(false) is never called.

After a reset, the field is cleared but stays type="text", so the next password typed is also shown in plain text.

PasswordToggleField.Input listens for the form's submit and reset events and calls setVisible(false) through useEffectEvent. The input is a forwardRef component, and on React 19.2.x the native useEffectEvent does not update its callback inside forwardRef components. The listeners therefore keep calling the setVisible from the first render. That function still compares against the initial visible value (false), so it treats the call as a no-op and never calls onVisibilityChange.

Uncontrolled usage (defaultVisible) isn't affected.

Expected behavior

Submitting or resetting the form hides the password again: onVisibilityChange(false) is called and the input goes back to type="password".

The same code behaves as expected on React 19.3.0.

Reproducible example

StackBlitz (React 19.2.8, radix-ui 1.6.7):

https://stackblitz.com/edit/raxw9yhq?file=src%2FApp.tsx

typescript
import * as React from 'react';
import { unstable_PasswordToggleField as PasswordToggleField } from 'radix-ui';

export default function App() {
  const [visible, setVisible] = React.useState(false);

  return (
    <form onSubmit={(event) => event.preventDefault()}>
      <PasswordToggleField.Root visible={visible} onVisibilityChange={setVisible}>
        <PasswordToggleField.Input name="password" />
        <PasswordToggleField.Toggle>Toggle</PasswordToggleField.Toggle>
      </PasswordToggleField.Root>

      <p>visible: {String(visible)}</p>

      <button type="submit">Submit</button>
      <button type="reset">Reset</button>
    </form>
  );
}
  1. Type a password and click "Toggle". The password is shown and visible: true.
  2. Click "Submit" or "Reset".
  3. On React 19.2.8, the password stays visible (type="text") and visible stays true.
  4. On React 19.3.0 (change react and react-dom in package.json), the password is hidden and visible becomes false.

Suggested solution

This is the same useEffectEvent-in-forwardRef problem as #4014, which #4015 worked around in DismissableLayer by using useCallbackRef instead of useEffectEvent.

The same workaround appears applicable here: wrap setVisible with useCallbackRef in PasswordToggleField.Input.

Additional context

Your environment

Software Name(s) Version
Radix Package(s) radix-ui (@radix-ui/react-password-toggle-field) 1.6.7 (0.1.11)
React react, react-dom 19.2.8
Browser Chromium 152.0.7977.130
Assistive tech n/a
Node n/a
npm/yarn/pnpm npm 10.9.8
Operating System macOS 26.6.2