Skip to content

HasManyFields mixes up values of uncontrolled inputs in rows #751

@tyleralves

Description

@tyleralves

I believe the cause is using indices as keys for rows combined with using uncontrolled inputs. Since we remap the HMF value after each change, the HMFRow keys will always be 0 to {value.length - 1}. When react reconciles, it deletes the last row because its key no longer exists. With controlled inputs the last row is still deleted, but this isn't a problem because the values are also reassigned.

STR:

  1. Pass template that contains uncontrolled inputs to HasManyFields
  2. Delete any row besides the last row

O:

  • Any uncontrolled input in the deleted row retains its value
  • Uncontrolled inputs in the last row are deleted
  • Any controlled input values are reassigned to proper row

D: Uncontrolled inputs should properly stay with the Rows they were created on

Here's a PR with a story that reproduces the bug:
#750

hmf_uncontrolled

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