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

Update to nested array items does not make isDirty become true #521

Closed
riceyeh opened this issue Sep 19, 2019 · 1 comment
Closed

Update to nested array items does not make isDirty become true #521

riceyeh opened this issue Sep 19, 2019 · 1 comment

Comments

@riceyeh
Copy link
Contributor

riceyeh commented Sep 19, 2019

The following example shows that update to nested array items does not make isDirty become true:

const fields = [
  'bulletin',
  'bulletin.jobs',
  'bulletin.jobs[].jobId',
  'bulletin.jobs[].companyName',
];

const values = {
  bulletin: {
    jobs: [
    {
      jobId: 1,
      companyName: 'Acer'
    },
    {
      jobId: 2,
      companyName: 'Asus'
    }]
  }
};

const $999 = new Form({fields, values}, {name: 'Form 999'})
// debugger
$999.update({
  bulletin: {
    jobs: [{
      jobId: 1,
      companyName: 'Apple'
    }]
  }
})
expect($999.$('bulletin.jobs').size).to.be.equal(1)
expect($999.$('bulletin.jobs.0.jobId').value).to.be.equal(1)
expect($999.$('bulletin.jobs.0.jobId').isDirty).to.be.equal(false)
expect($999.$('bulletin.jobs.0.companyName').value).to.be.equal('Apple')
expect($999.$('bulletin.jobs.0.companyName').isDirty).to.be.equal(true) //** but it is still false
expect($999.$('bulletin.jobs.0').isDirty).to.be.equal(true) //** but it is still false
expect($999.$('bulletin.jobs').isDirty).to.be.equal(true)

})

riceyeh added a commit to riceyeh/mobx-react-form that referenced this issue Sep 19, 2019
@foxhound87 foxhound87 added the fix label Sep 26, 2019
@foxhound87
Copy link
Owner

🎉 This issue has been resolved in version 2.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

2 participants