Skip to content

Commit 478300a

Browse files
committed
[fixed] Handle falsey DropdownMenu children correctly
1 parent 6a8ed3e commit 478300a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/DropdownMenu.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import keycode from 'keycode';
33
import classNames from 'classnames';
44
import RootCloseWrapper from 'react-overlays/lib/RootCloseWrapper';
5-
5+
import ValidComponentChildren from './utils/ValidComponentChildren';
66
import createChainedFunction from './utils/createChainedFunction';
77

88
class DropdownMenu extends React.Component {
@@ -77,7 +77,7 @@ class DropdownMenu extends React.Component {
7777
}
7878

7979
render() {
80-
const items = React.Children.map(this.props.children, child => {
80+
const items = ValidComponentChildren.map(this.props.children, child => {
8181
let {
8282
children,
8383
onKeyDown,

test/DropdownMenuSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ describe('DropdownMenu', function() {
7676
node.className.should.match(/\bdropdown-menu-right\b/);
7777
});
7878

79+
it('handles empty children', function() {
80+
ReactTestUtils.renderIntoDocument(
81+
<DropdownMenu pullRight>
82+
<MenuItem>Item</MenuItem>
83+
{ false && <MenuItem>Item 2</MenuItem> }
84+
</DropdownMenu>
85+
);
86+
});
87+
7988
describe('focusable state', function() {
8089
let focusableContainer;
8190

0 commit comments

Comments
 (0)