Skip to content

Commit b460abc

Browse files
committed
simpified the solution to fix double validation
1 parent f80af3e commit b460abc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/TableEditColumn.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ class TableEditColumn extends Component {
2828
const value = e.currentTarget.type === 'checkbox' ?
2929
this._getCheckBoxValue(e) : e.currentTarget.value;
3030

31-
// TAB triggers blur so no need to notify
32-
const notify = e.keyCode !== 9 || !this.props.blurToSave;
33-
if (!this.validator(value, notify)) {
31+
if ((e.keyCode === 9 && this.props.blurToSave) ||
32+
(!this.validator(value))) {
3433
return;
3534
}
3635

@@ -75,18 +74,18 @@ class TableEditColumn extends Component {
7574

7675
// modified by iuculanop
7776
// BEGIN
78-
validator(value, notify = true) {
77+
validator(value) {
7978
const ts = this;
8079
let valid = true;
8180
if (ts.props.editable.validator) {
8281
const checkVal = ts.props.editable.validator(value, this.props.row);
8382
const responseType = typeof checkVal;
8483
if (responseType !== 'object' && checkVal !== true) {
8584
valid = false;
86-
notify && this.notifyToastr('error', checkVal, '');
85+
this.notifyToastr('error', checkVal, '');
8786
} else if (responseType === 'object' && checkVal.isValid !== true) {
8887
valid = false;
89-
notify && this.notifyToastr(checkVal.notification.type,
88+
this.notifyToastr(checkVal.notification.type,
9089
checkVal.notification.msg,
9190
checkVal.notification.title);
9291
}

0 commit comments

Comments
 (0)