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

isDirty return false for update nested-nested array items #526

Closed
riceyeh opened this issue Oct 9, 2019 · 0 comments
Closed

isDirty return false for update nested-nested array items #526

riceyeh opened this issue Oct 9, 2019 · 0 comments

Comments

@riceyeh
Copy link
Contributor

riceyeh commented Oct 9, 2019

The following example shows updating to nested-nested array items does not make isDirty return true for the updated nested array item.

describe('add nested array items', () => {
it('', () => {
const fields = [
'pricing',
'pricing.value[]',
'pricing.value[].prices[]',
'pricing.value[].prices[].money',
'pricing.value[].prices[].quantity',
];

const values = {
  pricing: {
    value: [
      {
        prices: [{
          money: 35,
          quantity: 1
        }]
      }
    ]
  }
};
const $999 = new Form({fields, values}, {name: 'Form 999'})
console.debug('pricing.value.0.initial', $999.$('pricing.value.0').initial)
  console.debug('pricing.value.0.prices.initial', $999.$('pricing.value.0.prices').initial)
$999.update({
  pricing: {
    value: [
      {
        prices: [
          {
            money: 35,
            quantity: 1
          },
          {
            money: 100,
            quantity: 3
          }
        ]
      }
    ]
  }
})
console.debug('pricing.value.0.initial', $999.$('pricing.value.0').initial)
console.debug('pricing.value.0.prices.initial', $999.$('pricing.value.0.prices').initial)
expect($999.$('pricing.value').isDirty).to.be.equal(true)
expect($999.$('pricing.value.0').isDirty).to.be.equal(true) //** but return false for now.
expect($999.$('pricing.value.0.prices').isDirty).to.be.equal(true)

})
});

riceyeh added a commit to riceyeh/mobx-react-form that referenced this issue Oct 9, 2019
foxhound87 added a commit that referenced this issue Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants