Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Type: `String`

Placeholder text for the typeahead input.

#### props.textarea

Type: `Boolean`

Set to `true` to use a `<textarea>` element rather than an `<input>` element

#### props.inputProps

Type: `Object`
Expand Down
6 changes: 5 additions & 1 deletion src/typeahead/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var Typeahead = React.createClass({
allowCustomValues: React.PropTypes.number,
defaultValue: React.PropTypes.string,
placeholder: React.PropTypes.string,
textarea: React.PropTypes.bool,
inputProps: React.PropTypes.object,
onOptionSelected: React.PropTypes.func,
onChange: React.PropTypes.func,
Expand Down Expand Up @@ -56,6 +57,7 @@ var Typeahead = React.createClass({
allowCustomValues: 0,
defaultValue: "",
placeholder: "",
textarea: false,
inputProps: {},
onOptionSelected: function(option) {},
onChange: function(event) {},
Expand Down Expand Up @@ -249,10 +251,12 @@ var Typeahead = React.createClass({
classes[this.props.className] = !!this.props.className;
var classList = classNames(classes);

var InputElement = this.props.textarea ? 'textarea' : 'input';

return (
<div className={classList}>
{ this._renderHiddenInput() }
<input ref="entry" type="text"
<InputElement ref="entry" type="text"
{...this.props.inputProps}
placeholder={this.props.placeholder}
className={inputClassList}
Expand Down
21 changes: 21 additions & 0 deletions test/typeahead-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,26 @@ describe('Typeahead Component', function() {
});
});
});

context('textarea', function() {
it('should render a <textarea> input', function() {
var component = TestUtils.renderIntoDocument(<Typeahead
options={ BEATLES }
textarea={ true }
/>);

var input = component.refs.entry.getDOMNode();
assert.equal(input.tagName.toLowerCase(), 'textarea');
});

it('should render a <input> input', function() {
var component = TestUtils.renderIntoDocument(<Typeahead
options={ BEATLES }
/>);

var input = component.refs.entry.getDOMNode();
assert.equal(input.tagName.toLowerCase(), 'input');
});
})
});
});