final-form / final-form/react-final-form
[BUG] Cannot reset array of values using form.change function
- Dominant language
- JavaScript
- Stars
- 7.4k
- Forks
- 497
- PR merge metrics
- No merged PRs in 30d
Description
### Are you submitting a **bug report** or a **feature request**?
For me it's a bug.
### What is the current behavior?
I have nested fields that set different values of array. One of the fields
```
```
On top of the entire form I have a switcher where user can pick a different scenario. Picking different scenario resets array to the empty array.
I do it by using ``` change(`${prefix}.values`, [])``` but it doesn't work because `change` internally checks if there is any field that has the same "name" as the first argument of function and all of my fields have names like `${prefix}.values.[counter]`
### What is the expected behavior?
It supposed to be possible to change your array value using `form.change`
### Sandbox Link
### What's your environment?
"react-final-form": "3.5.0",
"final-form": "4.7.3",
### Other information
N/A
Contributor guide
Research direction
Start by reproducing the nested Field names such as `${prefix}.values.[counter]` and the `form.change(`${prefix}.values`, [])` call described in the issue. Read the behavior around `form.change` and field-name matching; done means changing the parent name resets the array value to an empty array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100