Skip to content

Commit 1531ac9

Browse files
committed
[added] DropdownButton now applies onClick prop to Button
1 parent af4c0a0 commit 1531ac9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: src/DropdownButton.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const DropdownButton = React.createClass({
3636
{...this.props}
3737
ref="dropdownButton"
3838
className={classNames('dropdown-toggle', this.props.buttonClassName)}
39-
onClick={this.handleDropdownClick}
39+
onClick={createChainedFunction(this.props.onClick, this.handleDropdownClick)}
4040
key={0}
4141
navDropdown={this.props.navItem}
4242
navItem={null}

Diff for: test/DropdownButtonSpec.js

+18
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,22 @@ describe('DropdownButton', function () {
213213
let button = ReactTestUtils.findRenderedComponentWithType(instance, Button).getDOMNode();
214214
assert.ok(button.className.match(/\btest-class\b/));
215215
});
216+
217+
it('should set onClick on Button', function (done) {
218+
function handleClick() {
219+
done();
220+
}
221+
222+
instance = ReactTestUtils.renderIntoDocument(
223+
<DropdownButton title="Title" onClick={handleClick}>
224+
<MenuItem eventKey='1'>MenuItem 1 content</MenuItem>
225+
<MenuItem eventKey='2'>MenuItem 2 content</MenuItem>
226+
</DropdownButton>
227+
);
228+
229+
let button = ReactTestUtils.findRenderedComponentWithType(instance, Button);
230+
ReactTestUtils.SimulateNative.click(
231+
ReactTestUtils.findRenderedDOMComponentWithClass(button, 'dropdown-toggle')
232+
);
233+
});
216234
});

0 commit comments

Comments
 (0)