Skip to content

Commit 4f4017e

Browse files
committedOct 17, 2015
[fixed] DropdownTitle children v. title
Prefer children for label, but default to title otherwise
1 parent 44182b7 commit 4f4017e

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed
 

‎src/DropdownToggle.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import classNames from 'classnames';
33
import Button from './Button';
4-
import singlePropFrom from 'react-prop-types/lib/singlePropFrom';
54
import SafeAnchor from './SafeAnchor';
65

76
const CARET = <span> <span className="caret" /></span>;
@@ -23,17 +22,12 @@ export default class DropdownToggle extends React.Component {
2322
type="button"
2423
aria-haspopup
2524
aria-expanded={this.props.open}>
26-
{this.props.title || this.props.children}{caret}
25+
{this.props.children || this.props.title}{caret}
2726
</Component>
2827
);
2928
}
3029
}
3130

32-
const titleAndChildrenValidation = singlePropFrom(
33-
'title',
34-
'children'
35-
);
36-
3731
DropdownToggle.defaultProps = {
3832
open: false,
3933
useAnchor: false,
@@ -42,10 +36,9 @@ DropdownToggle.defaultProps = {
4236

4337
DropdownToggle.propTypes = {
4438
bsRole: React.PropTypes.string,
45-
children: titleAndChildrenValidation,
4639
noCaret: React.PropTypes.bool,
4740
open: React.PropTypes.bool,
48-
title: titleAndChildrenValidation,
41+
title: React.PropTypes.string,
4942
useAnchor: React.PropTypes.bool
5043
};
5144

‎test/DropdownToggleSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('DropdownToggle', () => {
2727

2828
it('renders title children', () => {
2929
const instance = ReactTestUtils.renderIntoDocument(
30-
<DropdownToggle open={false}>
30+
<DropdownToggle title="toggle" open={false}>
3131
<h3>herpa derpa</h3>
3232
</DropdownToggle>
3333
);

0 commit comments

Comments
 (0)