|
|
@@ -19,14 +19,10 @@ export default class SearchForm extends React.Component {
|
|
|
this.onChange = this.onChange.bind(this);
|
|
|
}
|
|
|
|
|
|
- search() {
|
|
|
- if (this.state.searchedKeyword != this.state.keyword) {
|
|
|
- this.props.onSearchFormChanged({
|
|
|
- keyword: this.state.keyword
|
|
|
- });
|
|
|
- this.setState({
|
|
|
- searchedKeyword: this.state.keyword
|
|
|
- });
|
|
|
+ search(keyword) {
|
|
|
+ if (this.state.searchedKeyword != keyword) {
|
|
|
+ this.props.onSearchFormChanged({keyword: keyword});
|
|
|
+ this.setState({searchedKeyword: keyword});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -37,15 +33,12 @@ export default class SearchForm extends React.Component {
|
|
|
}
|
|
|
|
|
|
onSubmit(event) {
|
|
|
- // // get the closest form element
|
|
|
- // const elem = this.refs.form;
|
|
|
- // const form = elem.closest('form');
|
|
|
- // // submit with jQuery
|
|
|
- // $(form).submit();
|
|
|
if (event !== '') {
|
|
|
- event.preventDefault();
|
|
|
+ event.preventDefault(); // prevent refreshing page of form tag
|
|
|
}
|
|
|
- console.log(event);
|
|
|
+ const input = this.refs.searchTypeahead.state.input;
|
|
|
+ this.setState({keyword: input});
|
|
|
+ this.search(input);
|
|
|
}
|
|
|
|
|
|
onChange(selected) {
|
|
|
@@ -89,6 +82,7 @@ export default class SearchForm extends React.Component {
|
|
|
return (
|
|
|
<form ref='form' className="form form-group input-group" onSubmit={this.onSubmit}>
|
|
|
<SearchTypeahead
|
|
|
+ ref='searchTypeahead'
|
|
|
crowi={this.props.crowi}
|
|
|
onChange={this.onChange}
|
|
|
onSubmit={this.onSubmit}
|