Skip to content

Commit a16b38d

Browse files
merge master
2 parents 5081b3c + ecd8c6a commit a16b38d

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

docs/examples/InputTypes.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
var inputTypeInstance = (
22
<form>
3-
<Input type="text" defaultValue="text" />
4-
<Input type="password" defaultValue="secret" />
5-
<Input type="checkbox" checked readOnly label="checkbox"/>
6-
<Input type="radio" checked readOnly label="radio"/>
7-
<Input type="select" defaultValue="select">
3+
<Input type="text" label='Text' defaultValue="Enter text" />
4+
<Input type="email" label='Email Address' defaultValue="Enter email" />
5+
<Input type="password" label='Password' defaultValue="secret" />
6+
<Input type="file" label="File" help="[Optional] Block level help text" />
7+
<Input type="checkbox" label="Checkbox" checked readOnly />
8+
<Input type="radio" label="Radio" checked readOnly />
9+
<Input type="select" label='Select' defaultValue="select">
810
<option value="select">select</option>
911
<option value="other">...</option>
1012
</Input>
11-
<Input type="select" multiple>
13+
<Input type="select" label='Multiple Select' multiple>
1214
<option value="select">select (multiple)</option>
1315
<option value="other">...</option>
1416
</Input>
15-
<Input type="textarea" defaultValue="textarea" />
16-
<Input type="static" value="static" />
17-
<Input type="submit" bsStyle='primary' value="Submit button" />
17+
<Input type="textarea" label='Text Area' defaultValue="textarea" />
18+
<Input type="static" value="Static Text" />
19+
<Input type="submit" value="Submit button" />
1820
</form>
1921
);
2022

src/Input.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ var Input = React.createClass({
5050
return this.props.type === 'radio' || this.props.type === 'checkbox';
5151
},
5252

53+
isFile: function () {
54+
return this.props.type === 'file';
55+
},
56+
5357
renderInput: function () {
5458
var input = null;
5559

@@ -81,7 +85,7 @@ var Input = React.createClass({
8185
);
8286
break;
8387
default:
84-
var className = this.isCheckboxOrRadio() ? '' : 'form-control';
88+
var className = this.isCheckboxOrRadio() || this.isFile() ? '' : 'form-control';
8589
input = <input {...this.props} className={joinClasses(this.props.className, className)} ref="input" key="input" />;
8690
}
8791

test/InputSpec.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ describe('Input', function () {
136136
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'form-control-feedback'));
137137
});
138138

139+
it('renders file correctly', function () {
140+
var instance = ReactTestUtils.renderIntoDocument(
141+
<Input type="file" wrapperClassName="wrapper" label="Label" help="h" />
142+
);
143+
144+
var node = instance.getDOMNode();
145+
assert.include(node.className, 'form-group');
146+
assert.equal(node.children[0].tagName.toLowerCase(), 'label');
147+
assert.include(node.children[1].className, 'wrapper');
148+
assert.equal(node.children[1].children[0].tagName.toLowerCase(), 'input');
149+
assert.equal(node.children[1].children[0].className, '');
150+
assert.equal(node.children[1].children[0].type, 'file');
151+
assert.equal(node.children[1].children[1].className, 'help-block');
152+
});
153+
139154
it('renders checkbox/radio correctly', function () {
140155
var instance = ReactTestUtils.renderIntoDocument(
141156
<Input type="checkbox" wrapperClassName="wrapper" label="Label" help="h" />

0 commit comments

Comments
 (0)