Skip to content

Commit 0904adc

Browse files
committed
[added] Active property to MenuItem component
1 parent fb9b3bf commit 0904adc

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

docs/examples/DropdownButtonBasic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function renderDropdownButton (title, i) {
55
<DropdownButton bsStyle={title.toLowerCase()} title={title} key={i}>
66
<MenuItem eventKey='1'>Action</MenuItem>
77
<MenuItem eventKey='2'>Another action</MenuItem>
8-
<MenuItem eventKey='3'>Something else here</MenuItem>
8+
<MenuItem eventKey='3' active={true}>Active Item</MenuItem>
99
<MenuItem divider />
1010
<MenuItem eventKey='4'>Separated link</MenuItem>
1111
</DropdownButton>

src/MenuItem.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ const MenuItem = React.createClass({
99
title: React.PropTypes.string,
1010
target: React.PropTypes.string,
1111
onSelect: React.PropTypes.func,
12-
eventKey: React.PropTypes.any
12+
eventKey: React.PropTypes.any,
13+
active: React.PropTypes.bool
1314
},
1415

1516
getDefaultProps() {
1617
return {
17-
href: '#'
18+
href: '#',
19+
active: false
1820
};
1921
},
2022

@@ -36,7 +38,8 @@ const MenuItem = React.createClass({
3638
render() {
3739
let classes = {
3840
'dropdown-header': this.props.header,
39-
'divider': this.props.divider
41+
'divider': this.props.divider,
42+
'active': this.props.active
4043
};
4144

4245
let children = null;

test/MenuItemSpec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ describe('MenuItem', function () {
1818
<MenuItem
1919
className="test-class"
2020
href="#hi-mom!"
21-
title="hi mom!">
21+
title="hi mom!"
22+
active={true}>
2223
Title
2324
</MenuItem>
2425
);
@@ -27,6 +28,7 @@ describe('MenuItem', function () {
2728
assert(node.className.match(/\btest-class\b/));
2829
assert.equal(node.getAttribute('href'), null);
2930
assert.equal(node.getAttribute('title'), null);
31+
assert.ok(node.className.match(/\bactive\b/));
3032

3133
let anchorNode = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a').getDOMNode();
3234
assert.notOk(anchorNode.className.match(/\btest-class\b/));

0 commit comments

Comments
 (0)