Skip to content

issue: append from useFieldArray only appends if string inside array is non empty #10764

@harbar20

Description

@harbar20

Version Number

7.45.0

Codesandbox/Expo snack

https://codesandbox.io/s/recursing-liskov-t72nsf

Steps to reproduce

On the page, I have a button that says "Add Another Name." This adds another text input to the form that you can enter in. When you add a new name, it should create an empty text input that you can type into.

  1. On line 24, you see that I set the default value of the form to a single empty string. There's nothing.
  2. When you click the button, it adds a text input, but if you keep clicking it, there are no more text inputs added. This happens on line 73. The string here is empty. This works if the string contains something, whether that's a space or some text. This text does not show up in the text input itself. It just seems like the element you pass into it needs to be non-falsy.

Expected behaviour

At the beginning, there should be an empty text input with nothing inside that gets created even if you provide an empty string as a default in useForm. This works on Version 7.4.1, but not on the version I'm using here.

Same for when you add more text inputs. It only works with non-empty strings, but if you pass an empty string, it doesn't do anything. Works on Version 7.4.1.

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

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