diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-20 18:24:49 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-20 18:24:49 +0200 |
| commit | c6e1374b578581be32596f88146ff6cd948dfa3b (patch) | |
| tree | 24661e26d4b6c3d1e3dc012dd6e4168692189f91 /app/client/common/textInput.component.js | |
| parent | 59253e7a74399917de945bef200e3faa8aca73ce (diff) | |
send recordings to results page
Diffstat (limited to 'app/client/common/textInput.component.js')
| -rw-r--r-- | app/client/common/textInput.component.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/client/common/textInput.component.js b/app/client/common/textInput.component.js index 1e2ca01..a3739d4 100644 --- a/app/client/common/textInput.component.js +++ b/app/client/common/textInput.component.js @@ -3,14 +3,23 @@ import { h, Component } from 'preact' class TextInput extends Component { constructor(props){ super(props) + this.state = { value: null, changed: false } this.handleInput = this.handleInput.bind(this) this.handleKeydown = this.handleKeydown.bind(this) } handleInput(e){ + this.setState({ + value: e.target.value, + changed: true, + }) this.props.onInput && this.props.onInput(e.target.value) } handleKeydown(e){ if (e.keyCode === 13) { + this.setState({ + value: e.target.value, + changed: false, + }) this.props.onSave && this.props.onSave(e.target.value) } } @@ -21,7 +30,7 @@ class TextInput extends Component { <span>{this.props.title}</span> <input type='text' - value={this.props.value} + value={this.state.changed ? this.state.value : this.props.value} onInput={this.handleInput} onKeydown={this.handleKeydown} placeholder={this.props.placeholder} |
