|
@@ -27,7 +27,9 @@ export default class SearchTypeahead extends React.Component {
|
|
|
|
|
|
|
|
this.search = this.search.bind(this);
|
|
this.search = this.search.bind(this);
|
|
|
this.onInputChange = this.onInputChange.bind(this);
|
|
this.onInputChange = this.onInputChange.bind(this);
|
|
|
|
|
+ this.onKeyDown = this.onKeyDown.bind(this);
|
|
|
this.onChange = this.onChange.bind(this);
|
|
this.onChange = this.onChange.bind(this);
|
|
|
|
|
+ this.dispatchSubmit = this.dispatchSubmit.bind(this);
|
|
|
this.getRestoreFormButton = this.getRestoreFormButton.bind(this);
|
|
this.getRestoreFormButton = this.getRestoreFormButton.bind(this);
|
|
|
this.renderMenuItemChildren = this.renderMenuItemChildren.bind(this);
|
|
this.renderMenuItemChildren = this.renderMenuItemChildren.bind(this);
|
|
|
this.restoreInitialData = this.restoreInitialData.bind(this);
|
|
this.restoreInitialData = this.restoreInitialData.bind(this);
|
|
@@ -96,6 +98,12 @@ export default class SearchTypeahead extends React.Component {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ onKeyDown(event) {
|
|
|
|
|
+ if (event.keyCode === 13) {
|
|
|
|
|
+ this.dispatchSubmit();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
onChange(selected) {
|
|
onChange(selected) {
|
|
|
const page = selected[0]; // should be single page selected
|
|
const page = selected[0]; // should be single page selected
|
|
|
|
|
|
|
@@ -105,6 +113,12 @@ export default class SearchTypeahead extends React.Component {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ dispatchSubmit() {
|
|
|
|
|
+ if (this.props.onSubmit != null) {
|
|
|
|
|
+ this.props.onSubmit(this.state.keyword);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
renderMenuItemChildren(option, props, index) {
|
|
renderMenuItemChildren(option, props, index) {
|
|
|
const page = option;
|
|
const page = option;
|
|
|
return (
|
|
return (
|
|
@@ -162,6 +176,7 @@ export default class SearchTypeahead extends React.Component {
|
|
|
submitFormOnEnter={true}
|
|
submitFormOnEnter={true}
|
|
|
onSearch={this.search}
|
|
onSearch={this.search}
|
|
|
onInputChange={this.onInputChange}
|
|
onInputChange={this.onInputChange}
|
|
|
|
|
+ onKeyDown={this.onKeyDown}
|
|
|
renderMenuItemChildren={this.renderMenuItemChildren}
|
|
renderMenuItemChildren={this.renderMenuItemChildren}
|
|
|
caseSensitive={false}
|
|
caseSensitive={false}
|
|
|
defaultSelected={defaultSelected}
|
|
defaultSelected={defaultSelected}
|
|
@@ -205,6 +220,7 @@ SearchTypeahead.propTypes = {
|
|
|
onSearchSuccess: PropTypes.func,
|
|
onSearchSuccess: PropTypes.func,
|
|
|
onSearchError: PropTypes.func,
|
|
onSearchError: PropTypes.func,
|
|
|
onChange: PropTypes.func,
|
|
onChange: PropTypes.func,
|
|
|
|
|
+ onSubmit: PropTypes.func,
|
|
|
emptyLabel: PropTypes.string,
|
|
emptyLabel: PropTypes.string,
|
|
|
placeholder: PropTypes.string,
|
|
placeholder: PropTypes.string,
|
|
|
keywordOnInit: PropTypes.string,
|
|
keywordOnInit: PropTypes.string,
|