fix vairous bugs with submitting command; support more complex suggestions

This commit is contained in:
Iuri Matias 2018-10-13 17:03:24 -04:00 committed by Pascal Precht
parent 06ac5315a5
commit b2ef42df32
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 12 additions and 9 deletions

View File

@ -25,8 +25,8 @@ class Console extends Component {
this.typeahead.getInstance().clear()
}
handleChange(value) {
this.setState({value: value});
handleChange(value, cb) {
this.setState({value: value}, cb);
}
toggle(tab) {
@ -89,7 +89,6 @@ class Console extends Component {
</Card.Body>
{this.props.isEmbark() && <Card.Footer>
<AsyncTypeahead
search={value}
autoFocus={true}
emptyLabel={false}
labelKey="value"
@ -97,20 +96,25 @@ class Console extends Component {
emptyLabel={false}
maxResults={10}
isLoading={this.state.isLoading}
defaultInputValue={value}
onInputChange={(text) => this.handleChange(text)}
onChange={(text) => {
if (text && text[0]) {
this.handleChange(text[0].value)
}
}}
ref={(typeahead) => this.typeahead = typeahead}
searchText={false}
onKeyDown={(e) => {
if (e.keyCode === 13) {
this.handleChange(e.target.value, () => {
this.handleSubmit(e)
})
}
}}
onSearch={(value) => {
console.dir(value);
this.setState({ isLoading: false, options: [{value: 'hello', command_type: "embark", description: "says hello back!"}, {value: 'SimpleStorage', command_type: "web3 object", description: ""}, {value: 'web3.eth.getAccounts', command_type: "web3", description: "get list of accounts"}] })
}}
filterBy={['value']}
filterBy={['value', 'description']}
maxHeight="200px"
placeholder="Type a command (e.g help)"
options={this.state.options}
@ -123,7 +127,6 @@ class Console extends Component {
</div>
</div>
)}
/>
</Card.Footer>}
</Card>