Comments (5)
Looks like we have a bug here, I'll check it out later this week!
from form.
@crutchcorn You worked a lot on array fields, so I'll summon you to ask for help! π
If you check the video recording below, there are subfields in form.fieldMeta
:
"people[0].name"
"people[1].name"
When we delete "people[0].name"
, the values in form.values
are updated properly, but the meta data in form.fieldMeta
do not, because "people[0].name"
stays the same (instead of getting the value of "people[1].name"
), and "people[1].name"
simply gets deleted.
Kapture.2024-03-24.at.22.07.36.mp4
I could dig deeper, but I thought maybe you could give me some pointers here since you've worked with array fields recently.
from form.
@fulopkovacs do you think this is in part due to this? #662
from form.
@fulopkovacs do you think this is in part due to this? #662
They might be related, but I tested the PR of the supposed fix for #662 (#700), and it seems like it does not solve the issue.
I'll look into it! (Thanks to #656, I'm much more comfortable with working on validation-related issues π€£ )
from form.
Ok, I found the bug and made a fix locally, I will try to clean it up and commit it this week.
The main source of the problem is that the array field is not re-validated after one of its subfields gets removed. But, here are some interesting things that I found when I was investigating the issue:
- calling
validate()
on the array field itself did not re-validate the subfields (not sure if it's by accident or design), so I tried usingvalidateAllFields()
to quickly get the job done validateAllFields()
didn't work, because thefieldInfo
property ofFormApi
still contained data related to the deleted field, andvalidateAllFields()
relies on it to get the fields that should be validated- another fun fact: since the
removeValue()
method ofFieldApi
doesn't have anopts
arg ({touch: boolean}
), it can't pass it tothis.form.removeFieldValue
, which prevents the array field's meta data from being updated (it should happen here, it's fixed in #701 )
The fix I have locally deletes the data related to the last subfield from this.fieldInfo
in removeFieldValue()
before calling validateAllFields
. This way we don't have errors and everything gets updated properly.
from form.
Related Issues (20)
- Add a way to display only one error for a field HOT 3
- Calling `createFormFactory<FormData>` and using a validator adapter throw TS errors HOT 1
- onChangeAsyncDebounceMs not properly debouncing HOT 1
- TanStack/Angular - Error when resetting the form HOT 1
- Missing error when validating via form options instead of via field HOT 3
- Factory `onSubmit` function not invoked whenever factory.useForm gets provided with `onSubmit` itself HOT 2
- Unable to read properties in nested array table HOT 2
- Nested Values Disappear when using StrictMode HOT 5
- onMount Error is not revalidated when the user changes the input HOT 2
- server actions example errors when using zod adapter HOT 1
- Cannot infer types on arrays of union of objects HOT 1
- Moving subfields of array field mix their values HOT 1
- Bad performance with 100+ rows in an array field HOT 4
- insertFieldValue replaces item instead of adding a new one and shift existing items
- solid form createField failed to import `memo` from "solid-js/web" when used in solid-start ssr mode
- Issue with array + react + numbers HOT 2
- Nested Values Disappear when using StrictMode and `pushValue` HOT 1
- Incorrect field.state.value type
- Server Actions example leaks backend code
- Example for array usage lacks mode="array"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from form.