Skip to content

Commit

Permalink
[fixed] DropdownTitle children v. title
Browse files Browse the repository at this point in the history
Prefer children for label, but default to title otherwise
  • Loading branch information
taion committed Oct 17, 2015
1 parent 44182b7 commit 4f4017e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/DropdownToggle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import classNames from 'classnames';
import Button from './Button';
import singlePropFrom from 'react-prop-types/lib/singlePropFrom';
import SafeAnchor from './SafeAnchor';

const CARET = <span> <span className="caret" /></span>;
Expand All @@ -23,17 +22,12 @@ export default class DropdownToggle extends React.Component {
type="button"
aria-haspopup
aria-expanded={this.props.open}>
{this.props.title || this.props.children}{caret}
{this.props.children || this.props.title}{caret}
</Component>
);
}
}

const titleAndChildrenValidation = singlePropFrom(
'title',
'children'
);

DropdownToggle.defaultProps = {
open: false,
useAnchor: false,
Expand All @@ -42,10 +36,9 @@ DropdownToggle.defaultProps = {

DropdownToggle.propTypes = {
bsRole: React.PropTypes.string,
children: titleAndChildrenValidation,
noCaret: React.PropTypes.bool,
open: React.PropTypes.bool,
title: titleAndChildrenValidation,
title: React.PropTypes.string,
useAnchor: React.PropTypes.bool
};

Expand Down
2 changes: 1 addition & 1 deletion test/DropdownToggleSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('DropdownToggle', () => {

it('renders title children', () => {
const instance = ReactTestUtils.renderIntoDocument(
<DropdownToggle open={false}>
<DropdownToggle title="toggle" open={false}>
<h3>herpa derpa</h3>
</DropdownToggle>
);
Expand Down

0 comments on commit 4f4017e

Please sign in to comment.