react-hook-form icon indicating copy to clipboard operation
react-hook-form copied to clipboard

issue: Methods in ref are removed from other inputs in the Controller when one input is unmounted in the input array.

Open mmeitneriumm opened this issue 8 months ago • 0 comments

Version Number

7.54.2+

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/react-hook-form-usefieldarray-rules-forked-d9n5z5

Steps to reproduce

  1. Append inputs
  2. Remove last inputs
  3. First input don't have methods in ref (in control._fields..._f.ref)

Expected behaviour

_f.ref have focus, select methods

{
    "_f": {
        "ref": {
           focus()
           select()
           ...
         },
        "name": "test.0.lastName",
        "mount": true,
        "value": "Luo"
    }
}

What browsers are you seeing the problem on?

No response

Relevant log output

{
    "_f": {
        "ref": {
            "name": "test.0.lastName"
            // lost methods (focus,select,...)
        },
        "name": "test.0.lastName",
        "mount": true,
        "value": "Luo"
    }
}

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

mmeitneriumm avatar Jul 25 '25 14:07 mmeitneriumm