Skip to content

Commit 528d048

Browse files
authored
fix(AnalyticalTable): skip first table paint as long as column width has not been calculated (#406)
1 parent 6e3d549 commit 528d048

File tree

2 files changed

+47
-13
lines changed

2 files changed

+47
-13
lines changed

packages/main/src/components/AnalyticalTable/__snapshots__/AnalyticalTable.test.tsx.snap

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`AnalyticalTable Alternate Row Color 1`] = `
4-
<div>
4+
<div
5+
style="visibility: hidden;"
6+
>
57
<div
68
style="min-height: 1.5rem; display: flex; align-items: center;"
79
>
@@ -535,7 +537,9 @@ exports[`AnalyticalTable Alternate Row Color 1`] = `
535537
`;
536538

537539
exports[`AnalyticalTable Loading - Loader 1`] = `
538-
<div>
540+
<div
541+
style="visibility: hidden;"
542+
>
539543
<div
540544
style="min-height: 1.5rem; display: flex; align-items: center;"
541545
>
@@ -1069,7 +1073,9 @@ exports[`AnalyticalTable Loading - Loader 1`] = `
10691073
`;
10701074

10711075
exports[`AnalyticalTable Loading - Placeholder 1`] = `
1072-
<div>
1076+
<div
1077+
style="visibility: hidden;"
1078+
>
10731079
<div
10741080
style="min-height: 1.5rem; display: flex; align-items: center;"
10751081
>
@@ -1588,7 +1594,9 @@ exports[`AnalyticalTable Loading - Placeholder 1`] = `
15881594
`;
15891595

15901596
exports[`AnalyticalTable Tree Table 1`] = `
1591-
<div>
1597+
<div
1598+
style="visibility: hidden;"
1599+
>
15921600
<div
15931601
style="min-height: 1.5rem; display: flex; align-items: center;"
15941602
>
@@ -2301,7 +2309,9 @@ exports[`AnalyticalTable Tree Table 1`] = `
23012309
`;
23022310

23032311
exports[`AnalyticalTable custom row height 1`] = `
2304-
<div>
2312+
<div
2313+
style="visibility: hidden;"
2314+
>
23052315
<div
23062316
style="min-height: 1.5rem; display: flex; align-items: center;"
23072317
>
@@ -2835,7 +2845,9 @@ exports[`AnalyticalTable custom row height 1`] = `
28352845
`;
28362846

28372847
exports[`AnalyticalTable render without data 1`] = `
2838-
<div>
2848+
<div
2849+
style="visibility: hidden;"
2850+
>
28392851
<div
28402852
style="min-height: 1.5rem; display: flex; align-items: center;"
28412853
>
@@ -3127,7 +3139,9 @@ exports[`AnalyticalTable render without data 1`] = `
31273139
`;
31283140

31293141
exports[`AnalyticalTable test Asc desc 1`] = `
3130-
<div>
3142+
<div
3143+
style="visibility: hidden;"
3144+
>
31313145
<div
31323146
style="min-height: 1.5rem; display: flex; align-items: center;"
31333147
>
@@ -3661,7 +3675,9 @@ exports[`AnalyticalTable test Asc desc 1`] = `
36613675
`;
36623676

36633677
exports[`AnalyticalTable test Asc desc 2`] = `
3664-
<div>
3678+
<div
3679+
style="visibility: hidden;"
3680+
>
36653681
<div
36663682
style="min-height: 1.5rem; display: flex; align-items: center;"
36673683
>
@@ -4195,7 +4211,9 @@ exports[`AnalyticalTable test Asc desc 2`] = `
41954211
`;
41964212

41974213
exports[`AnalyticalTable test Asc desc 3`] = `
4198-
<div>
4214+
<div
4215+
style="visibility: hidden;"
4216+
>
41994217
<div
42004218
style="min-height: 1.5rem; display: flex; align-items: center;"
42014219
>
@@ -4729,7 +4747,9 @@ exports[`AnalyticalTable test Asc desc 3`] = `
47294747
`;
47304748

47314749
exports[`AnalyticalTable test drag and drop of a draggable column 1`] = `
4732-
<div>
4750+
<div
4751+
style="visibility: hidden;"
4752+
>
47334753
<div
47344754
style="min-height: 1.5rem; display: flex; align-items: center;"
47354755
>
@@ -5263,7 +5283,9 @@ exports[`AnalyticalTable test drag and drop of a draggable column 1`] = `
52635283
`;
52645284

52655285
exports[`AnalyticalTable with highlight row 1`] = `
5266-
<div>
5286+
<div
5287+
style="visibility: hidden;"
5288+
>
52675289
<div
52685290
style="min-height: 1.5rem; display: flex; align-items: center;"
52695291
>
@@ -5931,7 +5953,9 @@ exports[`AnalyticalTable with highlight row 1`] = `
59315953
`;
59325954

59335955
exports[`AnalyticalTable without selection Column 1`] = `
5934-
<div>
5956+
<div
5957+
style="visibility: hidden;"
5958+
>
59355959
<div
59365960
style="min-height: 1.5rem; display: flex; align-items: center;"
59375961
>

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,18 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
400400
[currentlyFocusedCell]
401401
);
402402

403+
const inlineStyle = useMemo(() => {
404+
if(tableState.tableClientWidth > 0) {
405+
return style;
406+
}
407+
return {
408+
...style,
409+
visibility: 'hidden' as 'hidden'
410+
};
411+
}, [tableState.tableClientWidth, style]);
412+
403413
return (
404-
<div className={className} style={style} title={tooltip} ref={analyticalTableRef} {...passThroughProps}>
414+
<div className={className} style={inlineStyle} title={tooltip} ref={analyticalTableRef} {...passThroughProps}>
405415
{title && <TitleBar>{title}</TitleBar>}
406416
{typeof renderExtension === 'function' && <div>{renderExtension()}</div>}
407417
<div className={tableContainerClasses.valueOf()} ref={tableRef}>

0 commit comments

Comments
 (0)