Skip to content

Commit efbcfc1

Browse files
authored
fix(AnalyticalTable): correctly indent root level tree rows (#1948)
1 parent a69c5e4 commit efbcfc1

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

packages/main/src/components/AnalyticalTable/defaults/Column/Expandable.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const isBrowserIe = isIE();
1414
const getPadding = (level) => {
1515
switch (level) {
1616
case 0:
17-
return 0;
17+
return '0px';
1818
case 1:
1919
return isBrowserIe ? '1rem' : CssSizeVariables.sapWcrAnalyticalTableTreePaddingLevel1;
2020
case 2:
@@ -29,7 +29,14 @@ const getPadding = (level) => {
2929
};
3030

3131
export const Expandable = (props) => {
32-
const { cell, row, column, columns, webComponentsReactProperties } = props;
32+
const {
33+
cell,
34+
row,
35+
column,
36+
columns,
37+
webComponentsReactProperties,
38+
state: { isRtl }
39+
} = props;
3340

3441
const tableColumns = columns.filter(
3542
({ id }) =>
@@ -39,15 +46,15 @@ export const Expandable = (props) => {
3946
);
4047

4148
const columnIndex = tableColumns.findIndex((col) => col.id === column.id);
42-
49+
const paddingRtl = isRtl ? 'paddingRight' : 'paddingLeft';
4350
let paddingLeft;
4451
if (row.canExpand) {
4552
paddingLeft = columnIndex === 0 ? getPadding(row.depth) : 0;
4653
} else {
4754
paddingLeft = columnIndex === 0 ? `calc(${getPadding(row.depth)} + 2rem)` : 0;
4855
}
4956
const style: CSSProperties = {
50-
paddingLeft
57+
[paddingRtl]: paddingLeft
5158
};
5259
const rowProps = row.getToggleRowExpandedProps();
5360

packages/main/src/components/AnalyticalTable/demo/generateData.ts

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,6 @@ const range = (len) => {
3030
return arr;
3131
};
3232

33-
const newEntry = () => {
34-
return {
35-
name: getRandomName(),
36-
age: getRandomNumber(18, 65),
37-
friend: {
38-
name: getRandomName(),
39-
age: getRandomNumber(18, 65)
40-
},
41-
status: [ValueState.None, ValueState.Information, ValueState.Success, ValueState.Warning, ValueState.Error][
42-
Math.floor(Math.random() * 4)
43-
]
44-
};
45-
};
46-
47-
const makeTreeEntry = (...lens) => {
48-
const makeDataLevel = (depth = 0) => {
49-
const len = lens[depth];
50-
return range(len).map((d) => {
51-
return {
52-
...newEntry(),
53-
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
54-
};
55-
});
56-
};
57-
return makeDataLevel();
58-
};
59-
6033
const makeEntry = () => ({
6134
name: getRandomName(),
6235
longColumn: 'Really really long column content... don´t crop please',
@@ -70,6 +43,22 @@ const makeEntry = () => ({
7043
]
7144
});
7245

46+
const makeTreeEntry = (...lens) => {
47+
const makeDataLevel = (depth = 0) => {
48+
const len = lens[depth];
49+
return range(len).map((d, index) => {
50+
if (index === 0) {
51+
return makeEntry();
52+
}
53+
return {
54+
...makeEntry(),
55+
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
56+
};
57+
});
58+
};
59+
return makeDataLevel();
60+
};
61+
7362
const generateData = (numEntries, isTree = false) => {
7463
if (isTree) {
7564
return makeTreeEntry(numEntries, 4, 4, 4);

0 commit comments

Comments
 (0)