diff --git a/components/autocomplete/index.jsx b/components/autocomplete/index.jsx index b4365852..104e056b 100644 --- a/components/autocomplete/index.jsx +++ b/components/autocomplete/index.jsx @@ -6,6 +6,7 @@ import utils from '../utils'; class Autocomplete extends React.Component { static propTypes = { + auto: React.PropTypes.bool, className: React.PropTypes.string, dataSource: React.PropTypes.any, disabled: React.PropTypes.bool, @@ -18,6 +19,7 @@ class Autocomplete extends React.Component { }; static defaultProps = { + auto: true, className: '', dataSource: {}, multiple: true @@ -73,13 +75,10 @@ class Autocomplete extends React.Component { handleFocus = () => { const client = event.target.getBoundingClientRect(); const screen_height = window.innerHeight || document.documentElement.offsetHeight; + const up = this.props.auto ? client.top > ((screen_height / 2) + client.height) : false; this.refs.suggestions.scrollTop = 0; - this.setState({ - active: '', - up: client.top > ((screen_height / 2) + client.height), - focus: true - }); + this.setState({active: '', up: up, focus: true}); }; handleBlur = () => { diff --git a/components/autocomplete/readme.md b/components/autocomplete/readme.md index 3b9ee541..48054c18 100644 --- a/components/autocomplete/readme.md +++ b/components/autocomplete/readme.md @@ -29,6 +29,7 @@ const AutocompleteTest = () => ( | Name | Type | Default | Description| |:-----|:-----|:-----|:-----| +| `auto` | `Boolean` | `true` | If true, the autocomplete will open to the best possible direction | | `className` | `String` | `''` | Sets a class to style of the Component.| | `dataSource` | `Object` or `Array` | | Object of key/values or array representing all items suggested.| | `disabled` | `Bool` | `false` | If true, component will be disabled.|