Skip to content

Commit

Permalink
Domains: don't normalize TXT record's data, only name
Browse files Browse the repository at this point in the history
A nice side-effect of this change is that the selected record does not
reset to 'A' after every submit.

Fixes #3328
  • Loading branch information
klimeryk committed Feb 26, 2016
1 parent e489bf2 commit ebfe7df
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions client/my-sites/upgrades/domain-management/dns/dns-add-new.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const DnsAddNew = React.createClass( {
getInitialState() {
return {
show: false,
fields: null
fields: null,
type: 'A'
};
},

Expand All @@ -54,13 +55,9 @@ const DnsAddNew = React.createClass( {
return assign( {}, Component.initialFields, { type } );
},

getInitialFields() {
return this.getFieldsForType( 'A' );
},

componentWillMount() {
this.formStateController = formState.Controller( {
initialFields: this.getInitialFields(),
initialFields: this.getFieldsForType( this.state.type ),
onNewState: this.setFormState,
validatorFunction: ( fieldValues, onComplete ) => {
onComplete( null, validateAllFields( fieldValues, this.props.selectedDomainName ) );
Expand Down Expand Up @@ -91,7 +88,7 @@ const DnsAddNew = React.createClass( {
formState.getAllFieldValues( this.state.fields ),
this.props.selectedDomainName
);
this.formStateController.resetFields( this.getInitialFields() );
this.formStateController.resetFields( this.getFieldsForType( this.state.type ) );

upgradesActions.addDns( this.props.selectedDomainName, normalizedData, ( error ) => {
if ( error ) {
Expand All @@ -107,14 +104,17 @@ const DnsAddNew = React.createClass( {
},

onChange( event ) {
const { name, value } = event.target,
skipNormalization = name === 'data' && this.state.type === 'TXT';
this.formStateController.handleFieldChange( {
name: event.target.name,
value: event.target.value.trim().toLowerCase()
name,
value: skipNormalization ? value : value.trim().toLowerCase(),
} );
},

changeType( event ) {
const fields = this.getFieldsForType( event.target.value );
this.setState( { type: event.target.value } );
this.formStateController.resetFields( fields );
},

Expand Down

0 comments on commit ebfe7df

Please sign in to comment.