Git Product home page Git Product logo

Comments (5)

fulopkovacs avatar fulopkovacs commented on May 29, 2024 1

Looks like we have a bug here, I'll check it out later this week! ☺️

from form.

fulopkovacs avatar fulopkovacs commented on May 29, 2024

@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.

crutchcorn avatar crutchcorn commented on May 29, 2024

@fulopkovacs do you think this is in part due to this? #662

from form.

fulopkovacs avatar fulopkovacs commented on May 29, 2024

@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.

fulopkovacs avatar fulopkovacs commented on May 29, 2024

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 using validateAllFields() to quickly get the job done
  • validateAllFields() didn't work, because the fieldInfo property of FormApi still contained data related to the deleted field, and validateAllFields() relies on it to get the fields that should be validated
  • another fun fact: since the removeValue() method of FieldApi doesn't have an opts arg ({touch: boolean}), it can't pass it to this.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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.