diff options
Diffstat (limited to 'scraper/client/common/autocomplete.component.js')
| -rw-r--r-- | scraper/client/common/autocomplete.component.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/scraper/client/common/autocomplete.component.js b/scraper/client/common/autocomplete.component.js index 03039b1c..e2908cd1 100644 --- a/scraper/client/common/autocomplete.component.js +++ b/scraper/client/common/autocomplete.component.js @@ -70,9 +70,9 @@ class Autocomplete extends Component { componentDidUpdate(oldProps) { if (this.props.vetting !== oldProps.vetting) { - this.handleChange({ target: { value: this.props.vetting }}) + this.handleChange({ target: { value: this.props.vetting } }) } else if (this.props.value !== oldProps.value) { - this.handleChange({ target: { value: this.props.value }}) + this.setState({ q: '' }) } } @@ -155,13 +155,14 @@ class Autocomplete extends Component { } handleSelect(name) { + console.log('select', name) if (this.props.onSelect) this.props.onSelect(name) - this.setState({ q: "", selected: 0, matches: [] }) + this.setState({ q: name, selected: 0, matches: [] }) } handleCancel() { if (this.props.onCancel) this.props.onCancel() - this.setState({ q: "", selected: 0, matches: [] }) + this.setState({ q: '', selected: 0, matches: [] }) } render() { @@ -184,7 +185,7 @@ class Autocomplete extends Component { <input type="text" name="q" - value={this.state.q} + value={this.state.q || this.props.value} onKeyDown={this.handleKeyDown} onChange={this.handleChange} autoFocus={this.props.autoFocus} |
