Skip to content

Commit 8049d1b

Browse files
author
Edward Xiao
committed
- Fix async problems with customFunc in <Textbox/> and <Textarea/>
1 parent 040f5ad commit 8049d1b

File tree

8 files changed

+52
-76
lines changed

8 files changed

+52
-76
lines changed

lib/components/Textarea.js

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ var component = function component(_ref) {
290290

291291
case 3:
292292
if (!type) {
293-
_context.next = 59;
293+
_context.next = 55;
294294
break;
295295
}
296296

297297
if (!(VALIDATE_OPTION_TYPE_LIST.indexOf(type) !== -1)) {
298-
_context.next = 56;
298+
_context.next = 52;
299299
break;
300300
}
301301

@@ -410,7 +410,7 @@ var component = function component(_ref) {
410410

411411
case 38:
412412
if (!(customFunc && typeof customFunc === 'function')) {
413-
_context.next = 52;
413+
_context.next = 48;
414414
break;
415415
}
416416

@@ -420,16 +420,8 @@ var component = function component(_ref) {
420420
case 41:
421421
customFuncResult = _context.sent;
422422

423-
if (!(typeof customFuncResult === 'undefined')) {
424-
_context.next = 46;
425-
break;
426-
}
427-
428-
return _context.abrupt("return");
429-
430-
case 46:
431423
if (!(_typeof(customFuncResult) === 'object')) {
432-
_context.next = 49;
424+
_context.next = 45;
433425
break;
434426
}
435427

@@ -443,37 +435,37 @@ var component = function component(_ref) {
443435

444436
return _context.abrupt("return");
445437

446-
case 49:
438+
case 45:
447439
if (!(customFuncResult !== true)) {
448-
_context.next = 52;
440+
_context.next = 48;
449441
break;
450442
}
451443

452444
handleCheckEnd(true, customFuncResult, true);
453445
return _context.abrupt("return");
454446

455-
case 52:
447+
case 48:
456448
if (msgOnSuccess) {
457449
setSuccessMsg(msgOnSuccess);
458450
}
459451

460452
handleCheckEnd(false, msgOnSuccess);
461-
_context.next = 57;
453+
_context.next = 53;
462454
break;
463455

464-
case 56:
456+
case 52:
465457
console.error("The valid ".concat(_utils["default"].toCamelCase(TYPE)(true), " \"type\" options in validationOption are [").concat(VALIDATE_OPTION_TYPE_LIST.map(function (i) {
466458
return i;
467459
}), "]"));
468460

469-
case 57:
470-
_context.next = 60;
461+
case 53:
462+
_context.next = 56;
471463
break;
472464

473-
case 59:
465+
case 55:
474466
console.error('Please provide "type" in validationOption');
475467

476-
case 60:
468+
case 56:
477469
case "end":
478470
return _context.stop();
479471
}

lib/components/Textbox.js

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ var component = function component(_ref) {
320320

321321
case 3:
322322
if (!type) {
323-
_context.next = 87;
323+
_context.next = 83;
324324
break;
325325
}
326326

327327
if (!(VALIDATE_OPTION_TYPE_LIST.indexOf(type) !== -1)) {
328-
_context.next = 84;
328+
_context.next = 80;
329329
break;
330330
}
331331

@@ -538,7 +538,7 @@ var component = function component(_ref) {
538538

539539
case 66:
540540
if (!(customFunc && typeof customFunc === 'function')) {
541-
_context.next = 80;
541+
_context.next = 76;
542542
break;
543543
}
544544

@@ -548,16 +548,8 @@ var component = function component(_ref) {
548548
case 69:
549549
customFuncResult = _context.sent;
550550

551-
if (!(typeof customFuncResult === 'undefined')) {
552-
_context.next = 74;
553-
break;
554-
}
555-
556-
return _context.abrupt("return");
557-
558-
case 74:
559551
if (!(_typeof(customFuncResult) === 'object')) {
560-
_context.next = 77;
552+
_context.next = 73;
561553
break;
562554
}
563555

@@ -571,37 +563,37 @@ var component = function component(_ref) {
571563

572564
return _context.abrupt("return");
573565

574-
case 77:
566+
case 73:
575567
if (!(customFuncResult !== true)) {
576-
_context.next = 80;
568+
_context.next = 76;
577569
break;
578570
}
579571

580572
handleCheckEnd(true, customFuncResult, true);
581573
return _context.abrupt("return");
582574

583-
case 80:
575+
case 76:
584576
if (msgOnSuccess) {
585577
setSuccessMsg(msgOnSuccess);
586578
}
587579

588580
handleCheckEnd(false, msgOnSuccess);
589-
_context.next = 85;
581+
_context.next = 81;
590582
break;
591583

592-
case 84:
584+
case 80:
593585
console.error("The valid ".concat(_utils["default"].toCamelCase(TYPE)(true), " \"type\" options in validationOption are [").concat(VALIDATE_OPTION_TYPE_LIST.map(function (i) {
594586
return i;
595587
}), "]"));
596588

597-
case 85:
598-
_context.next = 88;
589+
case 81:
590+
_context.next = 84;
599591
break;
600592

601-
case 87:
593+
case 83:
602594
console.error('Please provide "type" in validationOption');
603595

604-
case 88:
596+
case 84:
605597
case "end":
606598
return _context.stop();
607599
}

lib/react-inputs-validation.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/Inputs/Textarea.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,22 +247,18 @@ const component: React.FC<Props> = ({
247247
}
248248
if (customFunc && typeof customFunc === 'function') {
249249
const customFuncResult = await customFunc(internalValue);
250-
if (typeof customFuncResult === 'undefined') {
251-
return;
252-
} else {
253-
if (typeof customFuncResult === 'object') {
254-
if (typeof customFuncResult.error === 'boolean' && typeof customFuncResult.message === 'string') {
255-
if (customFuncResult.error === false && customFuncResult.showOnSuccess === true) {
256-
setSuccessMsg(customFuncResult.message);
257-
}
258-
handleCheckEnd(customFuncResult.error, customFuncResult.message, true);
250+
if (typeof customFuncResult === 'object') {
251+
if (typeof customFuncResult.error === 'boolean' && typeof customFuncResult.message === 'string') {
252+
if (customFuncResult.error === false && customFuncResult.showOnSuccess === true) {
253+
setSuccessMsg(customFuncResult.message);
259254
}
260-
return;
261-
}
262-
if (customFuncResult !== true) {
263-
handleCheckEnd(true, customFuncResult, true);
264-
return;
255+
handleCheckEnd(customFuncResult.error, customFuncResult.message, true);
265256
}
257+
return;
258+
}
259+
if (customFuncResult !== true) {
260+
handleCheckEnd(true, customFuncResult, true);
261+
return;
266262
}
267263
}
268264
if (msgOnSuccess) {

src/js/Inputs/Textbox.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,22 +312,18 @@ const component: React.FC<Props> = ({
312312
}
313313
if (customFunc && typeof customFunc === 'function') {
314314
const customFuncResult = await customFunc(internalValue);
315-
if (typeof customFuncResult === 'undefined') {
316-
return;
317-
} else {
318-
if (typeof customFuncResult === 'object') {
319-
if (typeof customFuncResult.error === 'boolean' && typeof customFuncResult.message === 'string') {
320-
if (customFuncResult.error === false && customFuncResult.showOnSuccess === true) {
321-
setSuccessMsg(customFuncResult.message);
322-
}
323-
handleCheckEnd(customFuncResult.error, customFuncResult.message, true);
315+
if (typeof customFuncResult === 'object') {
316+
if (typeof customFuncResult.error === 'boolean' && typeof customFuncResult.message === 'string') {
317+
if (customFuncResult.error === false && customFuncResult.showOnSuccess === true) {
318+
setSuccessMsg(customFuncResult.message);
324319
}
325-
return;
326-
}
327-
if (customFuncResult !== true) {
328-
handleCheckEnd(true, customFuncResult, true);
329-
return;
320+
handleCheckEnd(customFuncResult.error, customFuncResult.message, true);
330321
}
322+
return;
323+
}
324+
if (customFuncResult !== true) {
325+
handleCheckEnd(true, customFuncResult, true);
326+
return;
331327
}
332328
}
333329
if (msgOnSuccess) {

0 commit comments

Comments
 (0)