From e1b9c6f8b465d517f7360e07441d41141e092992 Mon Sep 17 00:00:00 2001 From: Javi Velasco Date: Sun, 1 Nov 2015 23:11:32 +0100 Subject: [PATCH] =?UTF-8?q?Missing=20stuff=20from=20the=20previos=20commit?= =?UTF-8?q?=20=F0=9F=98=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/autocomplete/index.jsx | 9 ++++----- components/autocomplete/readme.md | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) 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.|