Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FieldArray.pop doesn't remove touched on the removed field #1511

Open
andersem opened this issue May 15, 2019 · 3 comments
Open

FieldArray.pop doesn't remove touched on the removed field #1511

andersem opened this issue May 15, 2019 · 3 comments

Comments

@andersem
Copy link

andersem commented May 15, 2019

🐛 Bug report

FieldArray.pop doesn't remove touched on the removed field

Current Behavior

When I remove an element from an array with FieldArray.remove, the element is unmarked as touched. If I remove the element with FieldArray.pop, it's still marked as touched.

Expected behavior

I expect FieldArray.pop to have the same side effects as FieldArray.remove

Reproducible example

https://codesandbox.io/embed/rwl80mzvwo

Suggested solution(s)

Remove touched on the element removed by pop

Additional context

Your environment

Software Version(s)
Formik 1.5.0
React 16.8.0
TypeScript -
Browser Chrome 74.0
npm/Yarn npm 6.4.1
Operating System Windows 10
@andersem andersem changed the title FieldArray.pop doesn FieldArray.pop doesn't remove touched on the removed field May 15, 2019
@stale stale bot added the stale label Jul 19, 2019
@maddhruv
Copy link
Collaborator

maddhruv commented Nov 7, 2020

I am not able to replicate this on the codesandbox, is it that on popping the item is not removed from touched?

@andersem
Copy link
Author

If you add an item and click outside the input, you see that it's added to touched:

{
  "values": {
    "names": [
      "first_item"
    ]
  },
  "touched": {
    "names": [
      true
    ]
  }
}

When I remove the element, the item is removed, but it's still marked as touched:

{
  "values": {
    "names": []
  },
  "touched": {
    "names": [
      true
    ]
  }
}

@thoughtspile
Copy link

Hey guys, just came here goggling to fix a similar bug in our lib. Just wanted to tell you this issue is real, and related to TouchEvents spec. Here's some info:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants