Skip to content

issue: Duplicated checkboxes create the same values in array #11864

Closed
@damian-balas

Description

@damian-balas

Version Number

7.51.4

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/register-forked-cmmlpn

Steps to reproduce

  1. Select first checkbox
  2. Select first checkbox in red rectangle
  3. Submit
  4. Check console
  5. Output:
{
    "firstName": "",
    "lastName": "",
    "checkbox": [
        "A",
        "A"
    ],
    "radio": "",
    "message": ""
}

image

Expected behaviour

Checkboxes with the same registered name and value should "merge" and be in sync. If I select first checkbox, the first checkbox in red rectangle should be selected also.

before:

{
    "firstName": "",
    "lastName": "",
    "checkbox": [
        "A",
        "A"
    ],
    "radio": "",
    "message": ""
}

after:

{
    "firstName": "",
    "lastName": "",
    "checkbox": [
        "A",
    ],
    "radio": "",
    "message": ""
}

What's happening now (clicked only first checkbox):
image

What I want (clicked only first checkbox but the second one is in sync):
image

I want to duplicate all my inputs so I can show 50% of the form (4 inputs) on the initial view and 100% of the form (8 inputs) in a modal with a scrollbar.

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Edge

Relevant log output

No response

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions