Skip to content

Commit 9d532ea

Browse files
committed
fix(editor): fix undo for URL fields that initialize as null
refs #113
1 parent df4a06b commit 9d532ea

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/editor/components/EditorInput.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class EditorInput extends Component {
132132
case 'POSITIVE_NUM':
133133
case 'GTFS_BLOCK':
134134
case 'GTFS_FARE':
135-
case 'GTFS_SERVICE':
135+
case 'GTFS_SERVICE': {
136136
// Ensure that an empty string is passed to value prop, so that on 'undo'
137137
// the input value will revert back to a blank field.
138138
const stringValue = typeof fieldProps.value === 'undefined'
@@ -144,11 +144,17 @@ export default class EditorInput extends Component {
144144
<FormControl {...fieldProps} value={stringValue} />
145145
</FormGroup>
146146
)
147-
case 'URL':
147+
}
148+
case 'URL': {
149+
// Ensure that an empty string is passed to value prop, so that on 'undo'
150+
// the input value will revert back to a blank field.
151+
const stringValue = typeof fieldProps.value === 'undefined'
152+
? ''
153+
: fieldProps.value
148154
const elements = [
149155
<FormGroup {...formProps} key={`${editorField}-input`}>
150156
{basicLabel}
151-
<FormControl {...fieldProps} />
157+
<FormControl {...fieldProps} value={stringValue} />
152158
</FormGroup>
153159
]
154160
if (field.name === 'agency_branding_url' || field.name === 'route_branding_url') {
@@ -174,6 +180,7 @@ export default class EditorInput extends Component {
174180
)
175181
}
176182
return <span>{elements}</span>
183+
}
177184
case 'GTFS_ZONE':
178185
return (
179186
<FormGroup {...formProps}>

0 commit comments

Comments
 (0)