Skip to content

Commit

Permalink
fix(editor): fix undo for URL fields that initialize as null
Browse files Browse the repository at this point in the history
refs #113
  • Loading branch information
landonreed committed May 8, 2018
1 parent df4a06b commit 9d532ea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/editor/components/EditorInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class EditorInput extends Component {
case 'POSITIVE_NUM':
case 'GTFS_BLOCK':
case 'GTFS_FARE':
case 'GTFS_SERVICE':
case 'GTFS_SERVICE': {
// Ensure that an empty string is passed to value prop, so that on 'undo'
// the input value will revert back to a blank field.
const stringValue = typeof fieldProps.value === 'undefined'
Expand All @@ -144,11 +144,17 @@ export default class EditorInput extends Component {
<FormControl {...fieldProps} value={stringValue} />
</FormGroup>
)
case 'URL':
}
case 'URL': {
// Ensure that an empty string is passed to value prop, so that on 'undo'
// the input value will revert back to a blank field.
const stringValue = typeof fieldProps.value === 'undefined'
? ''
: fieldProps.value
const elements = [
<FormGroup {...formProps} key={`${editorField}-input`}>
{basicLabel}
<FormControl {...fieldProps} />
<FormControl {...fieldProps} value={stringValue} />
</FormGroup>
]
if (field.name === 'agency_branding_url' || field.name === 'route_branding_url') {
Expand All @@ -174,6 +180,7 @@ export default class EditorInput extends Component {
)
}
return <span>{elements}</span>
}
case 'GTFS_ZONE':
return (
<FormGroup {...formProps}>
Expand Down

0 comments on commit 9d532ea

Please sign in to comment.