@@ -47,13 +47,22 @@ export default class EditableTextField extends Component<Props, State> {
47
47
}
48
48
49
49
componentWillReceiveProps ( nextProps : Props ) {
50
- if ( this . state . value !== nextProps . value ) {
51
- // Update value if externally changed.
52
- this . setState ( { value : nextProps . value } )
50
+ const { initialValue, isEditing, value} = this . state
51
+ const { value : nextValue } = nextProps
52
+ const valueChanged = this . props . value !== nextValue
53
+ if ( value !== nextValue && valueChanged && ! isEditing ) {
54
+ // Update value if externally changed, but only if the field is not being
55
+ // actively edited. This update accounts for cases where the value this
56
+ // field represents has been updated (perhaps due to a request to the
57
+ // server), but if the user is already editing the field, we don't want to
58
+ // interrupt that input.
59
+ this . setState ( { value : nextValue } )
53
60
}
54
- if ( this . state . initialValue !== nextProps . value ) {
61
+ if ( initialValue !== nextValue ) {
55
62
// Update initial value if externally changed.
56
- this . setState ( { initialValue : nextProps . value } )
63
+ // TODO: investigate whether this conditional case fully accounts for the
64
+ // above conditional.
65
+ this . setState ( { initialValue : nextValue } )
57
66
}
58
67
}
59
68
@@ -141,6 +150,8 @@ export default class EditableTextField extends Component<Props, State> {
141
150
< FormGroup data-test-id = 'editable-text-field-edit-container' >
142
151
< InputGroup >
143
152
< FormControl
153
+ /* eslint-disable-next-line jsx-a11y/no-autofocus */
154
+ autoFocus
144
155
type = { type . toLowerCase ( ) }
145
156
min = { min }
146
157
step = { step }
0 commit comments