diff --git a/components/autocomplete/Autocomplete.jsx b/components/autocomplete/Autocomplete.jsx index 8d2e7d61..8a699f04 100644 --- a/components/autocomplete/Autocomplete.jsx +++ b/components/autocomplete/Autocomplete.jsx @@ -11,10 +11,16 @@ const POSITION = { UP: 'up' }; +const SELECTEDPOSITION = { + ABOVE: 'above', + BELOW: 'below' +}; + class Autocomplete extends React.Component { static propTypes = { className: React.PropTypes.string, direction: React.PropTypes.oneOf(['auto', 'up', 'down']), + selectedPosition: React.PropTypes.oneOf(['above', 'below']), disabled: React.PropTypes.bool, error: React.PropTypes.string, label: React.PropTypes.string, @@ -27,6 +33,7 @@ class Autocomplete extends React.Component { static defaultProps = { className: '', direction: 'auto', + selectedPosition: 'above', multiple: true, source: {} }; @@ -39,7 +46,7 @@ class Autocomplete extends React.Component { componentWillReceiveProps (nextProps) { if (!this.props.multiple) { - this.setState({query: this.query(nextProps.value)}); + this.setState({query: nextProps.value}); } } @@ -187,7 +194,7 @@ class Autocomplete extends React.Component { return (
- {this.renderSelected()} + {this.props.selectedPosition === 'above' ? this.renderSelected() : null} {this.renderSuggestions()} + {this.props.selectedPosition === 'below' ? this.renderSelected() : null}
); } diff --git a/components/autocomplete/readme.md b/components/autocomplete/readme.md index 12200f36..78fdda9a 100644 --- a/components/autocomplete/readme.md +++ b/components/autocomplete/readme.md @@ -26,6 +26,7 @@ class AutocompleteTest extends React.Component { return ( , /** @@ -177,7 +177,7 @@ declare namespace __RT { */ type?: string, /** - * Value or array of values currently selected component.Current value of the input element. + * Value or array of values currently selected component.Current value of the input element. */ value?: string | Array, }