Missing stuff from the previos commit 😂

old
Javi Velasco 2015-11-01 23:11:32 +01:00
parent 76e3f98c10
commit e1b9c6f8b4
2 changed files with 5 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import utils from '../utils';
class Autocomplete extends React.Component { class Autocomplete extends React.Component {
static propTypes = { static propTypes = {
auto: React.PropTypes.bool,
className: React.PropTypes.string, className: React.PropTypes.string,
dataSource: React.PropTypes.any, dataSource: React.PropTypes.any,
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
@ -18,6 +19,7 @@ class Autocomplete extends React.Component {
}; };
static defaultProps = { static defaultProps = {
auto: true,
className: '', className: '',
dataSource: {}, dataSource: {},
multiple: true multiple: true
@ -73,13 +75,10 @@ class Autocomplete extends React.Component {
handleFocus = () => { handleFocus = () => {
const client = event.target.getBoundingClientRect(); const client = event.target.getBoundingClientRect();
const screen_height = window.innerHeight || document.documentElement.offsetHeight; 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.refs.suggestions.scrollTop = 0;
this.setState({ this.setState({active: '', up: up, focus: true});
active: '',
up: client.top > ((screen_height / 2) + client.height),
focus: true
});
}; };
handleBlur = () => { handleBlur = () => {

View File

@ -29,6 +29,7 @@ const AutocompleteTest = () => (
| Name | Type | Default | Description| | 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.| | `className` | `String` | `''` | Sets a class to style of the Component.|
| `dataSource` | `Object` or `Array` | | Object of key/values or array representing all items suggested.| | `dataSource` | `Object` or `Array` | | Object of key/values or array representing all items suggested.|
| `disabled` | `Bool` | `false` | If true, component will be disabled.| | `disabled` | `Bool` | `false` | If true, component will be disabled.|