Skip to content

Commit

Permalink
[added] DropdownButton now applies onClick prop to Button
Browse files Browse the repository at this point in the history
  • Loading branch information
aforty committed May 15, 2015
1 parent af4c0a0 commit 1531ac9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DropdownButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const DropdownButton = React.createClass({
{...this.props}
ref="dropdownButton"
className={classNames('dropdown-toggle', this.props.buttonClassName)}
onClick={this.handleDropdownClick}
onClick={createChainedFunction(this.props.onClick, this.handleDropdownClick)}
key={0}
navDropdown={this.props.navItem}
navItem={null}
Expand Down
18 changes: 18 additions & 0 deletions test/DropdownButtonSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,22 @@ describe('DropdownButton', function () {
let button = ReactTestUtils.findRenderedComponentWithType(instance, Button).getDOMNode();
assert.ok(button.className.match(/\btest-class\b/));
});

it('should set onClick on Button', function (done) {
function handleClick() {
done();
}

instance = ReactTestUtils.renderIntoDocument(
<DropdownButton title="Title" onClick={handleClick}>
<MenuItem eventKey='1'>MenuItem 1 content</MenuItem>
<MenuItem eventKey='2'>MenuItem 2 content</MenuItem>
</DropdownButton>
);

let button = ReactTestUtils.findRenderedComponentWithType(instance, Button);
ReactTestUtils.SimulateNative.click(
ReactTestUtils.findRenderedDOMComponentWithClass(button, 'dropdown-toggle')
);
});
});

0 comments on commit 1531ac9

Please sign in to comment.