Skip to content

Commit 6bf39dd

Browse files
author
Julien Tassin
committed
bug on 0 / pair
1 parent 115c9c2 commit 6bf39dd

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

examples/src/FormExample.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
2+
import TextField from 'material-ui/TextField';
3+
import FlatButton from 'material-ui/FlatButton';
24
import Playground from 'component-playground';
35
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
46
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
57
import getMuiTheme from 'material-ui/styles/getMuiTheme';
68
import { Table, Row, Cell } from '../../src/index';
7-
import TextField from 'material-ui/TextField';
8-
import FlatButton from 'material-ui/FlatButton';
9+
910

1011
export default function render() {
1112
return (

src/Row/__tests__/Row.test.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ describe('Row', () => {
5252
describe('material', () => {
5353

5454
const MATERIAL_UNSTRIPED_ROW_RESULT = '<div style="display:flex;flex-direction:row;flex-wrap:wrap;flex-grow:0;width:100%;color:rgba(0, 0, 0, 0.87);min-height:48px;"></div>';
55+
56+
const MATERIAL_STRIPED_ROW_RESULT = '<div style="display:flex;flex-direction:row;flex-wrap:wrap;flex-grow:0;width:100%;color:rgba(0, 0, 0, 0.87);background-color:rgba(127, 221, 233, 0.4);min-height:48px;"></div>';
5557

5658
it('does not take striped boolean into account if material is false', () => {
5759
const wrapper = shallow(
@@ -71,10 +73,15 @@ describe('Row', () => {
7173
const wrapper = rowWrapper({material: true});
7274
expect(wrapper.html()).to.equal(MATERIAL_UNSTRIPED_ROW_RESULT);
7375
});
76+
77+
it('considers 0 index as pair', () => {
78+
const wrapper = rowWrapper({material: true, index: 0});
79+
expect(wrapper.html()).to.equal(MATERIAL_STRIPED_ROW_RESULT);
80+
});
7481

7582
it('add correct style if index is pair and striped is true', () => {
7683
const wrapper = rowWrapper({index: 2});
77-
expect(wrapper.html()).to.equal('<div style="display:flex;flex-direction:row;flex-wrap:wrap;flex-grow:0;width:100%;color:rgba(0, 0, 0, 0.87);background-color:rgba(127, 221, 233, 0.4);min-height:48px;"></div>');
84+
expect(wrapper.html()).to.equal(MATERIAL_STRIPED_ROW_RESULT);
7885
});
7986

8087
it('add correct style if index is impair and striped is true', () => {

src/Row/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Row.getStyles = (props, context) => {
4444
if (props.header) {
4545
style.borderBottom = `1px solid ${tableHeader.borderColor}`;
4646
}
47-
if (props.striped && props.index && (props.index % 2 === 0)) {
47+
if (props.striped && (props.index || props.index === 0) && (props.index % 2 === 0)) {
4848
style.backgroundColor = context.muiTheme.tableRow.stripeColor;
4949
}
5050
style.minHeight = context.muiTheme.tableRow.height;

0 commit comments

Comments
 (0)