@@ -41,15 +41,14 @@ export default class BasicInfo extends ConsentComponent {
41
41
42
42
const { userTraits } = props ;
43
43
this . state = {
44
- componentMounted : false ,
45
44
inputChanged : false ,
46
45
formInvalid : false ,
47
46
basicInfoTrait : this . loadBasicInfoTraits ( userTraits ) ,
48
47
personalizationTrait : this . loadPersonalizationTrait ( userTraits ) ,
49
48
newBasicInfo : {
50
49
handle : '' ,
51
- firstName : '' ,
52
- lastName : '' ,
50
+ firstName : null ,
51
+ lastName : null ,
53
52
gender : '' ,
54
53
ethnicBackground : null ,
55
54
shortBio : '' ,
@@ -82,9 +81,6 @@ export default class BasicInfo extends ConsentComponent {
82
81
const { basicInfoTrait } = this . state ;
83
82
const basicInfo = basicInfoTrait . traits ? basicInfoTrait . traits . data [ 0 ] : { } ;
84
83
this . processBasicInfo ( basicInfo ) ;
85
- this . setState ( {
86
- componentMounted : true ,
87
- } ) ;
88
84
}
89
85
90
86
componentWillReceiveProps ( nextProps ) {
@@ -381,6 +377,8 @@ export default class BasicInfo extends ConsentComponent {
381
377
}
382
378
if ( _ . has ( value , 'firstName' ) ) {
383
379
newBasicInfo . firstName = value . firstName ;
380
+ } else {
381
+ newBasicInfo . firstName = '' ;
384
382
}
385
383
if ( _ . has ( value , 'gender' ) ) {
386
384
newBasicInfo . gender = value . gender ;
@@ -394,6 +392,8 @@ export default class BasicInfo extends ConsentComponent {
394
392
}
395
393
if ( _ . has ( value , 'lastName' ) ) {
396
394
newBasicInfo . lastName = value . lastName ;
395
+ } else {
396
+ newBasicInfo . lastName = '' ;
397
397
}
398
398
if ( _ . has ( value , 'primaryInterestInTopcoder' ) ) {
399
399
newBasicInfo . primaryInterestInTopcoder = value . primaryInterestInTopcoder ;
@@ -465,7 +465,6 @@ export default class BasicInfo extends ConsentComponent {
465
465
const {
466
466
newBasicInfo,
467
467
inputChanged,
468
- componentMounted,
469
468
} = this . state ;
470
469
471
470
const canModifyTrait = ! this . props . traitRequestCount ;
@@ -506,7 +505,7 @@ export default class BasicInfo extends ConsentComponent {
506
505
< div styleName = "field col-2" >
507
506
< span styleName = "text-required" > * Required</ span >
508
507
< input disabled = { ! canModifyTrait } id = "firstName" name = "firstName" type = "text" placeholder = "First Name" onChange = { this . onUpdateInput } value = { newBasicInfo . firstName } maxLength = "64" required />
509
- < ErrorMessage invalid = { _ . isEmpty ( newBasicInfo . firstName ) && componentMounted } message = "First Name cannot be empty" />
508
+ < ErrorMessage invalid = { _ . isEmpty ( newBasicInfo . firstName ) && ! _ . isNull ( newBasicInfo . firstName ) && inputChanged } message = "First Name cannot be empty" />
510
509
</ div >
511
510
</ div >
512
511
< div styleName = "row" >
@@ -519,7 +518,7 @@ export default class BasicInfo extends ConsentComponent {
519
518
< div styleName = "field col-2" >
520
519
< span styleName = "text-required" > * Required</ span >
521
520
< input disabled = { ! canModifyTrait } id = "lastName" name = "lastName" type = "text" placeholder = "Last Name" onChange = { this . onUpdateInput } value = { newBasicInfo . lastName } maxLength = "64" required />
522
- < ErrorMessage invalid = { _ . isEmpty ( newBasicInfo . lastName ) && componentMounted } message = "Last Name cannot be empty" />
521
+ < ErrorMessage invalid = { _ . isEmpty ( newBasicInfo . lastName ) && ! _ . isNull ( newBasicInfo . lastName ) && inputChanged } message = "Last Name cannot be empty" />
523
522
</ div >
524
523
</ div >
525
524
< div styleName = "row" >
0 commit comments