OnRowUpdate and OnRowAdd diferent behaviours on return Promise.reject()
Not sure if that is the intended behaviour but it think not. This has been mentioned here #2086 and supposedly closed on PR #1998
OnRowAdd when you return Promise.reject() it let's you continue to edit the input fields and correct errors without loosing context.
Strangely, onRowUpdate doesn't follow the same behaviour, on receiving return Promise.reject() goes back to table and you have to press the edit button, loosing all information introduced until that point. This is the behaviour for return Promise.resolve() which would represent a successful edition.
Has someone noticed this behaviour diference? Does this make sense
editable={{
onRowAdd: newData => {
const validation = rawMaterialValidator(newData, mixtures)
if (validation.error) {
alertError(validation.error)
return Promise.reject()
} else {
return create(validation)
}
},
onRowUpdate: newData => {
const validation = rawMaterialValidator(newData, mixtures)
if (validation.error) {
alertError(validation.error)
return Promise.reject()
// TODO Instead of rejecting we are resolving, should be rejecting. Have to update library later github issue #2086
} else {
return update(newData.id, validation)
}
},
onRowDelete: oldData => remove(oldData.id)
}}
I am using the latest version 1.69.1
I have the same issue with version 1.61 and 1.68.
The reject works as expected if I remove the setState by not closing the edit mode but when I setState before the reject it closes the edit mode.
editable={{
onRowUpdate: (newData, oldData) => new Promise((resolve, reject) => {
setErrorObject({'test': 'test'})
reject()
})}}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.
This is still a bug and a very annoying one at that. I didn't even have to recreate any code there are plenty of examples out there.
https://codesandbox.io/s/materialtabledemo-validation-error-kgnww?file=/package.json If you open this sandbox which is locked into version 1.56.1, edit a row and empty the name column, save changes, the row will stay in edit mode with error message. This works all the way through ~1.58.0 but breaks after that. NEXT in the package.json change the material table version to ^1.56.1 (latest version of 1 but any version 1.59 or up has the issue), edit a row and empty the name column, save changes, the row exits edit mode and keeps the old data.
It seems the stale bot is make this code base worse by closing issues that are real and need addressing.
Hi All, is there anyone have solution for the issue? i am using version 2.0.3 but the bug persist,