diff --git a/src/ListGroup.js b/src/ListGroup.js
index dda67672a2..14714a6fb8 100644
--- a/src/ListGroup.js
+++ b/src/ListGroup.js
@@ -13,7 +13,7 @@ class ListGroup extends React.Component {
if (!this.props.children) {
return this.renderDiv(items);
- } else if (React.Children.count(this.props.children) === 1) {
+ } else if (React.Children.count(this.props.children) === 1 && !Array.isArray(this.props.children)) {
let child = this.props.children;
childrenAnchors = child.props.href ? true : false;
@@ -21,7 +21,9 @@ class ListGroup extends React.Component {
} else {
childrenAnchors = Array.prototype.some.call(this.props.children, (child) => {
- return child.props.href;
+ return !Array.isArray(child) ? child.props.href : Array.prototype.some.call(child, (subChild) => {
+ return subChild.props.href;
+ });
});
}
diff --git a/test/ListGroupSpec.js b/test/ListGroupSpec.js
index 3c9440c249..98ba2958b8 100644
--- a/test/ListGroupSpec.js
+++ b/test/ListGroupSpec.js
@@ -25,6 +25,19 @@ describe('ListGroup', function () {
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(items[0], 'list-group-item'));
});
+ it('Should support a single "ListGroupItem" child contained in an array', function () {
+ let child = [Only Child in array];
+ let instance = ReactTestUtils.renderIntoDocument(
+
+ {child}
+
+ );
+
+ let items = ReactTestUtils.scryRenderedComponentsWithType(instance, ListGroupItem);
+
+ assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(items[0], 'list-group-item'));
+ });
+
it('Should output a "ul" when single "ListGroupItem" child is a list item', function () {
let instance = ReactTestUtils.renderIntoDocument(
@@ -61,6 +74,26 @@ describe('ListGroup', function () {
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(items[1], 'list-group-item'));
});
+ it('Should support multiple "ListGroupItem" children including a subset contained in an array', function () {
+ let itemArray = [
+ 2nd Child nested,
+ 3rd Child nested
+ ];
+
+ let instance = ReactTestUtils.renderIntoDocument(
+
+ 1st Child
+ {itemArray}
+ 4th Child
+
+ );
+
+ let items = ReactTestUtils.scryRenderedComponentsWithType(instance, ListGroupItem);
+
+ assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(items[0], 'list-group-item'));
+ assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(items[1], 'list-group-item'));
+ });
+
it('Should output a "ul" when children are list items', function () {
let instance = ReactTestUtils.renderIntoDocument(