Skip to content

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

@mmeitneriumm

Description

@mmeitneriumm

Version Number

7.54.2+

Codesandbox/Expo snack

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions