From 7153989e1514c0ff4ffa344bc0ae5e2dc344843e Mon Sep 17 00:00:00 2001 From: Eric Giovanola Date: Wed, 7 Sep 2016 19:33:48 -0700 Subject: [PATCH] Add `dropup` prop --- example/example.js | 13 +++++++++---- package.json | 2 +- src/Typeahead.react.js | 11 +++++++++-- test/TypeaheadSpec.js | 10 ++++++++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/example/example.js b/example/example.js index babed08d..d2b4eca5 100644 --- a/example/example.js +++ b/example/example.js @@ -56,6 +56,7 @@ const Example = React.createClass({ customMenuItemChildren: false, customToken: false, disabled: false, + dropup: false, largeDataSet: false, minLength: 0, multiple: false, @@ -73,6 +74,7 @@ const Example = React.createClass({ customMenuItemChildren, customToken, disabled, + dropup, largeDataSet, minLength, multiple, @@ -81,7 +83,7 @@ const Example = React.createClass({ text, } = this.state; - let props = {allowNew, disabled, multiple, selected}; + const props = {align, allowNew, disabled, dropup, minLength, multiple, selected}; if (customMenuItemChildren) { props.renderMenuItemChildren = this._renderMenuItemChildren; @@ -108,16 +110,13 @@ const Example = React.createClass({
this.setState({selected})} onInputChange={text => this.setState({text})} options={largeDataSet ? bigData : states} placeholder="Choose a state..." ref="typeahead" - selected={selected} />
@@ -158,6 +157,12 @@ const Example = React.createClass({ onChange={this._handleChange}> Align menu: {this._renderAlignmentSelector()} + + Menu dropup + {this._renderInput(results)} {this._renderMenu(results, shouldPaginate)} diff --git a/test/TypeaheadSpec.js b/test/TypeaheadSpec.js index 9a3361fe..06c5c40c 100644 --- a/test/TypeaheadSpec.js +++ b/test/TypeaheadSpec.js @@ -148,4 +148,14 @@ describe('', () => { expect(paginatorNodes.length).to.equal(0); }); + it('should add the `dropup` className when `dropup=true`', () => { + const instance = getTypeaheadInstance({...baseProps, dropup: true}); + const TypeaheadNode = ReactTestUtils.findRenderedDOMComponentWithClass( + instance, + 'dropup' + ); + + expect(TypeaheadNode).to.exist; + }); + });