Skip to content

Commit 5e8fce5

Browse files
authored
Merge pull request #660 from jbetancur/fix/651
fix conditionalRowStyles when using striped convenience prop
2 parents 5fa8a9b + b82b91a commit 5e8fce5

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-data-table-component",
3-
"version": "6.11.0",
3+
"version": "6.11.1",
44
"description": "A declarative react based data table",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.es.js",

src/DataTable/TableRow.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import TableCell from './TableCell';
55
import TableCellCheckbox from './TableCellCheckbox';
66
import TableCellExpander from './TableCellExpander';
77
import ExpanderRow from './ExpanderRow';
8-
import { getConditionalStyle } from './util';
8+
import { getConditionalStyle, isOdd } from './util';
99

1010
const STOP_PROP_TAG = '___react-data-table-allow-propagation___';
1111

@@ -97,13 +97,14 @@ const TableRow = memo(({
9797
const extendedRowStyle = getConditionalStyle(row, conditionalRowStyles);
9898
const hightlightSelected = selectableRowsHighlight && selected;
9999
const inheritStyles = inheritConditionalStyles ? extendedRowStyle : null;
100+
const isStriped = striped && isOdd(rowIndex);
100101

101102
return (
102103
<>
103104
<TableRowStyle
104105
id={`row-${id}`}
105106
role="row"
106-
striped={striped}
107+
striped={isStriped}
107108
highlightOnHover={highlightOnHover}
108109
pointerOnHover={!defaultExpanderDisabled && showPointer}
109110
dense={dense}

src/DataTable/__tests__/__snapshots__/DataTable.test.js.snap

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48593,11 +48593,34 @@ exports[`DataTable::striped should render correctly when striped 1`] = `
4859348593
border-bottom-color: rgba(0,0,0,.12);
4859448594
}
4859548595

48596-
.c14:nth-of-type(odd) {
48596+
.c16 {
48597+
display: -webkit-box;
48598+
display: -webkit-flex;
48599+
display: -ms-flexbox;
48600+
display: flex;
48601+
-webkit-align-items: stretch;
48602+
-webkit-box-align: stretch;
48603+
-ms-flex-align: stretch;
48604+
align-items: stretch;
48605+
-webkit-align-content: stretch;
48606+
-ms-flex-line-pack: stretch;
48607+
align-content: stretch;
48608+
width: 100%;
48609+
box-sizing: border-box;
48610+
font-size: 13px;
48611+
color: rgba(0,0,0,0.87);
48612+
background-color: #FFFFFF;
48613+
min-height: 48px;
4859748614
color: rgba(0,0,0,0.87);
4859848615
background-color: #FAFAFA;
4859948616
}
4860048617

48618+
.c16:not(:last-of-type) {
48619+
border-bottom-style: solid;
48620+
border-bottom-width: 1px;
48621+
border-bottom-color: rgba(0,0,0,.12);
48622+
}
48623+
4860148624
.c11 {
4860248625
position: relative;
4860348626
display: -webkit-box;
@@ -48915,7 +48938,7 @@ exports[`DataTable::striped should render correctly when striped 1`] = `
4891548938
</div>
4891648939
</div>
4891748940
<div
48918-
class="c14 rdt_TableRow"
48941+
class="c16 rdt_TableRow"
4891948942
id="row-2"
4892048943
role="row"
4892148944
>

src/DataTable/styles.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ export const defaultStyles = theme => ({
129129
outlineColor: theme.background.default,
130130
},
131131
stripedStyle: {
132-
'&:nth-of-type(odd)': {
133-
color: theme.striped.text,
134-
backgroundColor: theme.striped.default,
135-
},
132+
color: theme.striped.text,
133+
backgroundColor: theme.striped.default,
136134
},
137135
},
138136
expanderRow: {

src/DataTable/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,7 @@ export const detectRTL = (direction = 'auto') => {
133133

134134
return direction === 'rtl';
135135
};
136+
137+
export const isOdd = num => {
138+
return num % 2;
139+
};

0 commit comments

Comments
 (0)