summaryrefslogtreecommitdiff
path: root/app/client/common/textInput.component.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2018-06-20 12:29:36 -0400
committerJules <jules@asdf.us>2018-06-20 12:29:36 -0400
commit89c3c2546af95122099e5e3e7cc0c40448066508 (patch)
tree226bcc92ebbfab003339ffbd346a90421d9c6fe0 /app/client/common/textInput.component.js
parent95de035728c209a6d0acee9b14a86837e44d26e4 (diff)
parent78abe1dc85c7b251cc871ffd4630a4a6c5eb2bd4 (diff)
oop
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}