Skip to content

Commit dae7513

Browse files
committed
fix: table ellipsis not work at fixed column #2916 #3021
1 parent 5597ec0 commit dae7513

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

components/table/__tests__/__snapshots__/demo.test.js.snap

+10-10
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ exports[`renders ./antdv-demo/docs/table/demo/fixed-columns.md correctly 1`] = `
10231023
<!---->
10241024
<div class="ant-table-body-outer">
10251025
<div class="ant-table-body-inner">
1026-
<table class="ant-table-fixed">
1026+
<table class="ant-table-fixed" style="width: 200px;">
10271027
<colgroup>
10281028
<col style="width: 100px; min-width: 100px;">
10291029
<col style="width: 100px; min-width: 100px;">
@@ -1054,7 +1054,7 @@ exports[`renders ./antdv-demo/docs/table/demo/fixed-columns.md correctly 1`] = `
10541054
<!---->
10551055
<div class="ant-table-body-outer">
10561056
<div class="ant-table-body-inner">
1057-
<table class="ant-table-fixed">
1057+
<table class="ant-table-fixed" style="width: 100px;">
10581058
<colgroup>
10591059
<col style="width: 100px; min-width: 100px;">
10601060
</colgroup>
@@ -1291,7 +1291,7 @@ exports[`renders ./antdv-demo/docs/table/demo/fixed-columns-header.md correctly
12911291
</div>
12921292
<div class="ant-table-fixed-left">
12931293
<div class="ant-table-header">
1294-
<table class="ant-table-fixed">
1294+
<table class="ant-table-fixed" style="width: 200px;">
12951295
<colgroup>
12961296
<col style="width: 100px; min-width: 100px;">
12971297
<col style="width: 100px; min-width: 100px;">
@@ -1308,7 +1308,7 @@ exports[`renders ./antdv-demo/docs/table/demo/fixed-columns-header.md correctly
13081308
</div>
13091309
<div class="ant-table-body-outer">
13101310
<div class="ant-table-body-inner" style="max-height: 300px; overflow-y: scroll;">
1311-
<table class="ant-table-fixed">
1311+
<table class="ant-table-fixed" style="width: 200px;">
13121312
<colgroup>
13131313
<col style="width: 100px; min-width: 100px;">
13141314
<col style="width: 100px; min-width: 100px;">
@@ -1361,7 +1361,7 @@ exports[`renders ./antdv-demo/docs/table/demo/fixed-columns-header.md correctly
13611361
</div>
13621362
<div class="ant-table-fixed-right">
13631363
<div class="ant-table-header">
1364-
<table class="ant-table-fixed">
1364+
<table class="ant-table-fixed" style="width: 100px;">
13651365
<colgroup>
13661366
<col style="width: 100px; min-width: 100px;">
13671367
</colgroup>
@@ -1375,7 +1375,7 @@ exports[`renders ./antdv-demo/docs/table/demo/fixed-columns-header.md correctly
13751375
</div>
13761376
<div class="ant-table-body-outer">
13771377
<div class="ant-table-body-inner" style="max-height: 300px; overflow-y: scroll;">
1378-
<table class="ant-table-fixed">
1378+
<table class="ant-table-fixed" style="width: 100px;">
13791379
<colgroup>
13801380
<col style="width: 100px; min-width: 100px;">
13811381
</colgroup>
@@ -1919,7 +1919,7 @@ exports[`renders ./antdv-demo/docs/table/demo/grouping-columns.md correctly 1`]
19191919
</div>
19201920
<div class="ant-table-fixed-left">
19211921
<div class="ant-table-header">
1922-
<table class="ant-table-fixed">
1922+
<table class="ant-table-fixed" style="width: 100px;">
19231923
<colgroup>
19241924
<col style="width: 100px; min-width: 100px;">
19251925
</colgroup>
@@ -1935,7 +1935,7 @@ exports[`renders ./antdv-demo/docs/table/demo/grouping-columns.md correctly 1`]
19351935
</div>
19361936
<div class="ant-table-body-outer">
19371937
<div class="ant-table-body-inner" style="max-height: 240px; overflow-y: scroll;">
1938-
<table class="ant-table-fixed">
1938+
<table class="ant-table-fixed" style="width: 100px;">
19391939
<colgroup>
19401940
<col style="width: 100px; min-width: 100px;">
19411941
</colgroup>
@@ -1977,7 +1977,7 @@ exports[`renders ./antdv-demo/docs/table/demo/grouping-columns.md correctly 1`]
19771977
</div>
19781978
<div class="ant-table-fixed-right">
19791979
<div class="ant-table-header">
1980-
<table class="ant-table-fixed">
1980+
<table class="ant-table-fixed" style="width: 80px;">
19811981
<colgroup>
19821982
<col style="width: 80px; min-width: 80px;">
19831983
</colgroup>
@@ -1991,7 +1991,7 @@ exports[`renders ./antdv-demo/docs/table/demo/grouping-columns.md correctly 1`]
19911991
</div>
19921992
<div class="ant-table-body-outer">
19931993
<div class="ant-table-body-inner" style="max-height: 240px; overflow-y: scroll;">
1994-
<table class="ant-table-fixed">
1994+
<table class="ant-table-fixed" style="width: 80px;">
19951995
<colgroup>
19961996
<col style="width: 80px; min-width: 80px;">
19971997
</colgroup>

components/table/__tests__/__snapshots__/empty.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ exports[`Table renders empty table with fixed columns 1`] = `
176176
<!---->
177177
<div class="ant-table-body-outer">
178178
<div class="ant-table-body-inner">
179-
<table class="ant-table-fixed">
179+
<table class="ant-table-fixed" style="width: 200px;">
180180
<colgroup>
181181
<col style="width: 100px; min-width: 100px;">
182182
<col style="width: 100px; min-width: 100px;">
@@ -198,7 +198,7 @@ exports[`Table renders empty table with fixed columns 1`] = `
198198
<!---->
199199
<div class="ant-table-body-outer">
200200
<div class="ant-table-body-inner">
201-
<table class="ant-table-fixed">
201+
<table class="ant-table-fixed" style="width: 100px;">
202202
<colgroup>
203203
<col style="width: 100px; min-width: 100px;">
204204
</colgroup>

components/vc-table/src/BaseTable.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const BaseTable = {
146146
render() {
147147
const { sComponents: components, prefixCls, scroll, data, getBodyWrapper } = this.table;
148148
const { expander, tableClassName, hasHead, hasBody, fixed, isAnyColumnsFixed } = this.$props;
149-
149+
const columns = this.getColumns();
150150
const tableStyle = {};
151151

152152
if (!fixed && scroll.x) {
@@ -158,6 +158,14 @@ const BaseTable = {
158158
tableStyle.width =
159159
typeof tableStyle.width === 'number' ? `${tableStyle.width}px` : tableStyle.width;
160160
}
161+
if(fixed) {
162+
const width = columns.reduce((sum, {width: w})=>{
163+
return sum + parseFloat(w, 10);
164+
}, 0);
165+
if(width > 0) {
166+
tableStyle.width = width + 'px';
167+
}
168+
}
161169

162170
const Table = hasBody ? components.table : 'table';
163171
const BodyWrapper = components.body.wrapper;
@@ -169,7 +177,6 @@ const BaseTable = {
169177
body = getBodyWrapper(body);
170178
}
171179
}
172-
const columns = this.getColumns();
173180
return (
174181
<Table class={tableClassName} style={tableStyle} key="table">
175182
<ColGroup columns={columns} fixed={fixed} />

0 commit comments

Comments
 (0)