diff --git a/src/List/ListItem.js b/src/List/ListItem.js
index 8d849f8441605e..a8c26817a31e81 100644
--- a/src/List/ListItem.js
+++ b/src/List/ListItem.js
@@ -641,12 +641,12 @@ class ListItem extends Component {
) : undefined;
- const hasCheckbox = leftCheckbox || rightToggle;
+ const simpleLabel = !primaryTogglesNestedList && (leftCheckbox || rightToggle);
return (
{
- hasCheckbox ? this.createLabelElement(styles, contentChildren, other) :
+ simpleLabel ? this.createLabelElement(styles, contentChildren, other) :
disabled ? this.createDisabledElement(styles, contentChildren, other) : (
', () => {
assert.strictEqual(wrapper.find(`.${testClass}`).length, 1, 'should have a div with the test class');
});
+ describe('props: primaryTogglesNestedList', () => {
+ it('should toggle nested list when true', () => {
+ const wrapper = shallowWithContext(
+ }
+ primaryText="Item text"
+ primaryTogglesNestedList={true}
+ nestedItems={[
+ ,
+ ]}
+ />
+ );
+ const primaryTextButton = wrapper.find('EnhancedButton');
+
+ assert.strictEqual(wrapper.find(NestedList).props().open, false);
+
+ primaryTextButton.simulate('touchTap', {stopPropagation: () => {}});
+ assert.strictEqual(wrapper.find(NestedList).props().open, true);
+
+ primaryTextButton.simulate('touchTap', {stopPropagation: () => {}});
+ assert.strictEqual(wrapper.find(NestedList).props().open, false);
+ });
+
+ it('should not render primary text button when false', () => {
+ const wrapper = shallowWithContext(
+ }
+ primaryText="Item text"
+ primaryTogglesNestedList={false}
+ nestedItems={[
+ ,
+ ]}
+ />
+ );
+
+ assert.strictEqual(wrapper.filter('EnhancedButton').length, 0);
+ });
+ });
+
describe('props: open', () => {
it('should initially open nested list', () => {
const wrapper = shallowWithContext(