diff options
Diffstat (limited to 'src/components/modals/TextInputModal.js')
| -rw-r--r-- | src/components/modals/TextInputModal.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/components/modals/TextInputModal.js b/src/components/modals/TextInputModal.js index 97986fe2..e4a55372 100644 --- a/src/components/modals/TextInputModal.js +++ b/src/components/modals/TextInputModal.js @@ -11,14 +11,20 @@ class TextInputModal extends React.Component { initialValue: PropTypes.string, }; + componentDidUpdate() { + if (this.props.initialValue) { + this.textInput.value = this.props.initialValue; + } + } + onSubmit() { - this.props.callback(this.refs.textInput.value); - this.refs.textInput.value = ""; + this.props.callback(this.textInput.value); + this.textInput.value = ""; } onCancel() { this.props.callback(undefined); - this.refs.textInput.value = ""; + this.textInput.value = ""; } render() { @@ -33,7 +39,8 @@ class TextInputModal extends React.Component { }}> <div className="form-group"> <label className="form-control-label">{this.props.label}:</label> - <input type="text" className="form-control" ref="textInput" value={this.props.initialValue}/> + <input type="text" className="form-control" + ref={textInput => this.textInput = textInput}/> </div> </form> </Modal> |
