summaryrefslogtreecommitdiff
path: root/app/client/common/textInput.component.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/common/textInput.component.js')
-rw-r--r--app/client/common/textInput.component.js11
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}