@@ -41,15 +41,14 @@ export default class BasicInfo extends ConsentComponent {
4141
4242 const { userTraits } = props ;
4343 this . state = {
44- componentMounted : false ,
4544 inputChanged : false ,
4645 formInvalid : false ,
4746 basicInfoTrait : this . loadBasicInfoTraits ( userTraits ) ,
4847 personalizationTrait : this . loadPersonalizationTrait ( userTraits ) ,
4948 newBasicInfo : {
5049 handle : '' ,
51- firstName : '' ,
52- lastName : '' ,
50+ firstName : null ,
51+ lastName : null ,
5352 gender : '' ,
5453 ethnicBackground : null ,
5554 shortBio : '' ,
@@ -82,9 +81,6 @@ export default class BasicInfo extends ConsentComponent {
8281 const { basicInfoTrait } = this . state ;
8382 const basicInfo = basicInfoTrait . traits ? basicInfoTrait . traits . data [ 0 ] : { } ;
8483 this . processBasicInfo ( basicInfo ) ;
85- this . setState ( {
86- componentMounted : true ,
87- } ) ;
8884 }
8985
9086 componentWillReceiveProps ( nextProps ) {
@@ -381,6 +377,8 @@ export default class BasicInfo extends ConsentComponent {
381377 }
382378 if ( _ . has ( value , 'firstName' ) ) {
383379 newBasicInfo . firstName = value . firstName ;
380+ } else {
381+ newBasicInfo . firstName = '' ;
384382 }
385383 if ( _ . has ( value , 'gender' ) ) {
386384 newBasicInfo . gender = value . gender ;
@@ -394,6 +392,8 @@ export default class BasicInfo extends ConsentComponent {
394392 }
395393 if ( _ . has ( value , 'lastName' ) ) {
396394 newBasicInfo . lastName = value . lastName ;
395+ } else {
396+ newBasicInfo . lastName = '' ;
397397 }
398398 if ( _ . has ( value , 'primaryInterestInTopcoder' ) ) {
399399 newBasicInfo . primaryInterestInTopcoder = value . primaryInterestInTopcoder ;
@@ -465,7 +465,6 @@ export default class BasicInfo extends ConsentComponent {
465465 const {
466466 newBasicInfo,
467467 inputChanged,
468- componentMounted,
469468 } = this . state ;
470469
471470 const canModifyTrait = ! this . props . traitRequestCount ;
@@ -506,7 +505,7 @@ export default class BasicInfo extends ConsentComponent {
506505 < div styleName = "field col-2" >
507506 < span styleName = "text-required" > * Required</ span >
508507 < 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" />
510509 </ div >
511510 </ div >
512511 < div styleName = "row" >
@@ -519,7 +518,7 @@ export default class BasicInfo extends ConsentComponent {
519518 < div styleName = "field col-2" >
520519 < span styleName = "text-required" > * Required</ span >
521520 < 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" />
523522 </ div >
524523 </ div >
525524 < div styleName = "row" >
0 commit comments