From 478300a4e7c173f8dfe048c5261843b4f29becf0 Mon Sep 17 00:00:00 2001 From: jquense Date: Fri, 28 Aug 2015 11:49:52 -0400 Subject: [PATCH] [fixed] Handle falsey DropdownMenu children correctly --- src/DropdownMenu.js | 4 ++-- test/DropdownMenuSpec.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/DropdownMenu.js b/src/DropdownMenu.js index ed81eb21fe..eb79dd6a52 100644 --- a/src/DropdownMenu.js +++ b/src/DropdownMenu.js @@ -2,7 +2,7 @@ import React from 'react'; import keycode from 'keycode'; import classNames from 'classnames'; import RootCloseWrapper from 'react-overlays/lib/RootCloseWrapper'; - +import ValidComponentChildren from './utils/ValidComponentChildren'; import createChainedFunction from './utils/createChainedFunction'; class DropdownMenu extends React.Component { @@ -77,7 +77,7 @@ class DropdownMenu extends React.Component { } render() { - const items = React.Children.map(this.props.children, child => { + const items = ValidComponentChildren.map(this.props.children, child => { let { children, onKeyDown, diff --git a/test/DropdownMenuSpec.js b/test/DropdownMenuSpec.js index b3e7e56d7f..2bab8c5a46 100644 --- a/test/DropdownMenuSpec.js +++ b/test/DropdownMenuSpec.js @@ -76,6 +76,15 @@ describe('DropdownMenu', function() { node.className.should.match(/\bdropdown-menu-right\b/); }); + it('handles empty children', function() { + ReactTestUtils.renderIntoDocument( + + Item + { false && Item 2 } + + ); + }); + describe('focusable state', function() { let focusableContainer;