Skip to content

Commit 012bcf4

Browse files
committed
fix(Table): inconsistent width between Firefox and Chrome
1 parent a426b62 commit 012bcf4

File tree

6 files changed

+167
-459
lines changed

6 files changed

+167
-459
lines changed

packages/components/table/BaseTable.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,6 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
311311
if (col.minWidth) {
312312
style.minWidth = formatCSSUnit(col.minWidth);
313313
}
314-
// 没有设置任何宽度的场景下,需要保留表格正常显示的最小宽度,否则会出现因宽度过小的抖动问题
315-
if (!style.width && !col.minWidth && props.tableLayout === 'fixed') {
316-
style.minWidth = '80px';
317-
}
318314
return <col key={col.colKey || index} style={style} />;
319315
})}
320316
</colgroup>

packages/components/table/__tests__/__snapshots__/pagination.test.tsx.snap

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,9 @@ exports[`BaseTable Pagination > locale data pagination controlled > pagination.c
148148
class="t-table--layout-fixed"
149149
>
150150
<colgroup>
151-
<col
152-
style="min-width: 80px;"
153-
/>
154-
<col
155-
style="min-width: 80px;"
156-
/>
157-
<col
158-
style="min-width: 80px;"
159-
/>
151+
<col />
152+
<col />
153+
<col />
160154
</colgroup>
161155
<thead
162156
class="t-table__header"

packages/components/table/__tests__/__snapshots__/vitest-table.test.jsx.snap

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@ exports[`BaseTable Component > props.showHeader: BaseTable contains element \`th
1313
class="t-table--layout-fixed"
1414
>
1515
<colgroup>
16-
<col
17-
style="min-width: 80px;"
18-
/>
19-
<col
20-
style="min-width: 80px;"
21-
/>
22-
<col
23-
style="min-width: 80px;"
24-
/>
16+
<col />
17+
<col />
18+
<col />
2519
</colgroup>
2620
<thead
2721
class="t-table__header"
@@ -168,15 +162,9 @@ exports[`BaseTable Component > props.size is equal to large 1`] = `
168162
class="t-table--layout-fixed"
169163
>
170164
<colgroup>
171-
<col
172-
style="min-width: 80px;"
173-
/>
174-
<col
175-
style="min-width: 80px;"
176-
/>
177-
<col
178-
style="min-width: 80px;"
179-
/>
165+
<col />
166+
<col />
167+
<col />
180168
</colgroup>
181169
<thead
182170
class="t-table__header"
@@ -323,15 +311,9 @@ exports[`BaseTable Component > props.size is equal to medium 1`] = `
323311
class="t-table--layout-fixed"
324312
>
325313
<colgroup>
326-
<col
327-
style="min-width: 80px;"
328-
/>
329-
<col
330-
style="min-width: 80px;"
331-
/>
332-
<col
333-
style="min-width: 80px;"
334-
/>
314+
<col />
315+
<col />
316+
<col />
335317
</colgroup>
336318
<thead
337319
class="t-table__header"
@@ -478,15 +460,9 @@ exports[`BaseTable Component > props.size is equal to small 1`] = `
478460
class="t-table--layout-fixed"
479461
>
480462
<colgroup>
481-
<col
482-
style="min-width: 80px;"
483-
/>
484-
<col
485-
style="min-width: 80px;"
486-
/>
487-
<col
488-
style="min-width: 80px;"
489-
/>
463+
<col />
464+
<col />
465+
<col />
490466
</colgroup>
491467
<thead
492468
class="t-table__header"
@@ -782,15 +758,9 @@ exports[`BaseTable Component > props.tableLayout is equal to fixed 1`] = `
782758
class="t-table--layout-fixed"
783759
>
784760
<colgroup>
785-
<col
786-
style="min-width: 80px;"
787-
/>
788-
<col
789-
style="min-width: 80px;"
790-
/>
791-
<col
792-
style="min-width: 80px;"
793-
/>
761+
<col />
762+
<col />
763+
<col />
794764
</colgroup>
795765
<thead
796766
class="t-table__header"

packages/components/table/_example/fixed-header-col.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
2-
import { Table, Radio, Checkbox, Space, Tag, Link } from 'tdesign-react';
3-
import { ErrorCircleFilledIcon, CheckCircleFilledIcon, CloseCircleFilledIcon } from 'tdesign-icons-react';
2+
import { CheckCircleFilledIcon, CloseCircleFilledIcon, ErrorCircleFilledIcon } from 'tdesign-icons-react';
3+
import { Checkbox, Link, Radio, Space, Table, Tag } from 'tdesign-react';
44

55
import type { TableProps } from 'tdesign-react';
66

@@ -19,7 +19,6 @@ for (let i = 0; i < 20; i++) {
1919
index: i,
2020
applicant: ['贾明', '张三', '王芳'][i % 3],
2121
status: i % 3,
22-
channel: ['电子签署', '纸质签署', '纸质签署'][i % 3],
2322
detail: {
2423
email: ['w.cezkdudy@lhll.au', 'r.nmgw@peurezgn.sl', 'p.cumx@rampblpa.ru'][i % 3],
2524
},
@@ -42,7 +41,7 @@ export default function TableFixedColumn() {
4241
footData={[{}]}
4342
tableLayout={tableLayout}
4443
tableContentWidth={tableLayout === 'fixed' ? undefined : '1600px'}
45-
maxHeight={fixedTopAndBottomRows ? 500 : 300}
44+
maxHeight={500}
4645
fixedRows={fixedTopAndBottomRows ? [2, 2] : undefined}
4746
columns={[
4847
{ colKey: 'applicant', title: '申请人', width: '100', foot: '共20条', fixed: 'left' },
@@ -65,7 +64,6 @@ export default function TableFixedColumn() {
6564
);
6665
},
6766
},
68-
{ colKey: 'channel', title: '签署方式' },
6967
{ colKey: 'matters', title: '申请事项', width: '150', foot: '-' },
7068
{ colKey: 'detail.email', title: '邮箱地址' },
7169
{ colKey: 'createTime', title: '申请日期', width: '120', foot: '-' },

0 commit comments

Comments
 (0)