Skip to content

Commit

Permalink
[ListItemText] Fix primary={0} display (#11686)
Browse files Browse the repository at this point in the history
* Display 0's with ListItemText

* 🌹
  • Loading branch information
helfi92 authored and mbrookes committed Jun 2, 2018
1 parent 64b4dac commit 4927668
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/material-ui/src/ListItemText/ListItemText.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ function ListItemText(props, context) {
} = props;
const { dense } = context;

let primary = primaryProp || children;
if (primary && !disableTypography) {
let primary = primaryProp != null ? primaryProp : children;
if (primary != null && !disableTypography) {
primary = (
<Typography
variant="subheading"
Expand All @@ -61,7 +61,7 @@ function ListItemText(props, context) {
}

let secondary = secondaryProp;
if (secondary && !disableTypography) {
if (secondary != null && !disableTypography) {
secondary = (
<Typography
variant="body1"
Expand Down
10 changes: 10 additions & 0 deletions packages/material-ui/src/ListItemText/ListItemText.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ describe('<ListItemText />', () => {
const wrapper = shallow(<ListItemText>{primary}</ListItemText>);
assert.strictEqual(wrapper.contains(primary), true, 'should find the node');
});

it('should read 0 as primary', () => {
const wrapper = shallow(<ListItemText primary={0} />);
assert.strictEqual(wrapper.childAt(0).type(), Typography);
});
});

describe('prop: secondary', () => {
Expand Down Expand Up @@ -91,6 +96,11 @@ describe('<ListItemText />', () => {
const wrapper = shallow(<ListItemText secondary={secondary} />);
assert.strictEqual(wrapper.contains(secondary), true, 'should find the node');
});

it('should read 0 as secondary', () => {
const wrapper = shallow(<ListItemText secondary={0} />);
assert.strictEqual(wrapper.childAt(0).type(), Typography);
});
});

describe('prop: disableTypography', () => {
Expand Down

0 comments on commit 4927668

Please sign in to comment.