-
-
Notifications
You must be signed in to change notification settings - Fork 129
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 is always true when initiating a Separated Properties with an array that has initial NULL value #531
Comments
I temporarily hook into individual fields |
This problem has nothing to do with array. I simplify your example as shown below. It is not an array, but it still fails. The current isDirty implementation does not work for fields (including form) having nested fields. But it should work for fields without nested fields after some bugs fixed by some pull requests from me. I privately implement isDirty-like method for fields with nested fields. Some assumptions are made in my implementation, so I do not bring it to mobx-react-form. For example, is a field dirty when some nested fields are added to it? describe('isDrity with inital null values', () => {
it('', () => {
const fields = [
'action',
'action.applyBy',
'action.amount',
]
const labels = {
'action.applyBy': 'Apply By',
'action.amount': 'Discount Amount',
}
const types = {
'action.amount': 'number',
}
const values = {
action: {
applyBy: null,
amount: null,
}
}
const $531 = new Form({fields, labels, types, values}, {name: 'Form 531', options:{fallback: false}})
expect($531.$('action.applyBy').isDirty).to.be.false
expect($531.$('action.amount').isDirty).to.be.false
expect($531.$('action').isDirty).to.be.false // fails
expect($531.isDirty).to.be.false // fails
})
}); |
hi @riceyeh Thank you. In unified, IsDirty works fine but I guess there's no nested field yet. |
I need IsDirty to work for nested fields. For now, I hook to every field's onChange event as a workaround |
created a test, this is happening only when defining null values |
🎉 This issue has been resolved in version 5.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi,
I am using Separated Properties with array of nested properties. I the array has initial value, the isDirty is set to true, but if the array has no initial values the isDirty is correctly set to false.
Here is a repl.it example:
Mobx-React-Form Seperated Properties Array isDirty
I am already using v2.0.8
The text was updated successfully, but these errors were encountered: