Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions packages/components/table/hooks/useFixed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,16 @@ export default function useFixed(
};

const updateTableWidth = () => {
// 确保数据渲染后再获取宽度,避免数据更新后可能存在滚动条
// 导致元素宽度再次更新,产生闪烁
setTimeout(() => {
const tRef = tableContentRef.current;
const rect = tRef?.getBoundingClientRect?.();
if (!rect) return;
// 存在纵向滚动条,且固定表头时,需去除滚动条宽度
const reduceWidth = isFixedHeader ? scrollbarWidth : 0;
tableWidth.current = rect.width - reduceWidth - (props.bordered ? 1 : 0);
const elmRect = tableElmRef?.current?.getBoundingClientRect();
if (elmRect?.width) {
setTableElmWidth(elmRect?.width);
}
}, 0);
const tRef = tableContentRef.current;
const rect = tRef?.getBoundingClientRect?.();
if (!rect) return;
// 存在纵向滚动条,且固定表头时,需去除滚动条宽度
const reduceWidth = isFixedHeader ? scrollbarWidth : 0;
tableWidth.current = rect.width - reduceWidth - (props.bordered ? 1 : 0);
const elmRect = tableElmRef?.current?.getBoundingClientRect();
if (elmRect?.width) {
setTableElmWidth(elmRect?.width);
}
};

// 在表格高度变化的时候 需要手动调整affix的位置 因为affix本身无法监听到这些变化触发重新计算
Expand Down Expand Up @@ -436,9 +432,7 @@ export default function useFixed(
if (!thead) return;
updateThWidthList(thead.children);
clearTimeout(timer);
// 将 Table 放在 Dialog 等使用 CSSTransition 包裹的元素
// 动画效果影响元素宽度的计算时机
}, 150);
}, 0);
};

const emitScrollEvent = (e: React.WheelEvent<HTMLDivElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/tdesign-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ spline: explain
## 🌈 1.13.1 `2025-07-11`

### 🐞 Bug Fixes
- `QRCode`: 修复 `canvas` 二维码 Safari 样式兼容问题 @lifeiFront ([common#2207])(https://github.com/Tencent/tdesign-common/pull/2207)
- `QRCode`: 修复 `canvas` 二维码 Safari 样式兼容问题 @lifeiFront ([common#2207](https://github.com/Tencent/tdesign-common/pull/2207))

## 🌈 1.13.0 `2025-07-10`
### 🚀 Features
Expand Down
188 changes: 186 additions & 2 deletions test/snap/__snapshots__/csr.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99713,8 +99713,125 @@ exports[`csr snapshot test > csr test packages/components/table/_example/affix.t
<div>
<div
class="t-table__affixed-header-elm-wrap"
style="width: 0px; height: 0px; opacity: 1;"
/>
style="width: -1px; height: 0px; opacity: 1;"
>
<div
class="scrollbar t-table__affixed-header-elm"
style="width: -2px; opacity: 1;"
>
<table
class="t-table--layout-fixed"
>
<colgroup>
<col
style="width: 120px;"
/>
<col
style="width: 150px;"
/>
<col
style="width: 120px;"
/>
<col
style="min-width: 80px;"
/>
<col
style="min-width: 80px;"
/>
<col
style="min-width: 80px;"
/>
<col
style="width: 120px;"
/>
</colgroup>
<thead
class="t-table__header"
>
<tr>
<th
class="t-table__th-applicant t-table__th--drag-sort"
data-colkey="applicant"
>
<div
class="t-table__th-cell-inner"
>
申请人
</div>
</th>
<th
class="t-table__th-status t-table__th--drag-sort"
data-colkey="status"
>
<div
class="t-table__th-cell-inner"
>
申请状态
</div>
</th>
<th
class="t-table__th-channel t-table__th--drag-sort"
data-colkey="channel"
>
<div
class="t-table__th-cell-inner"
>
签署方式
</div>
</th>
<th
class="t-table__th-detail.email t-table__th--drag-sort"
data-colkey="detail.email"
>
<div
class="t-table__th-cell-inner"
>
<div
class="t-table__ellipsis t-text-ellipsis"
>
邮箱地址
</div>
</div>
</th>
<th
class="t-table__th-matters t-table__th--drag-sort"
data-colkey="matters"
>
<div
class="t-table__th-cell-inner"
>
<div
class="t-table__ellipsis t-text-ellipsis"
>
申请事项
</div>
</div>
</th>
<th
class="t-table__th-createTime t-table__th--drag-sort"
data-colkey="createTime"
>
<div
class="t-table__th-cell-inner"
>
申请时间
</div>
</th>
<th
class="t-table__th-operation t-table__th--drag-sort"
data-colkey="operation"
>
<div
class="t-table__th-cell-inner"
>
操作
</div>
</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
<div
Expand Down Expand Up @@ -100174,6 +100291,73 @@ exports[`csr snapshot test > csr test packages/components/table/_example/affix.t
</tfoot>
</table>
</div>
<div
class="t-table__affixed-footer-wrap"
style="margin-top: -1px;"
>
<div>
<div
class="scrollbar t-table__affixed-footer-elm"
style="width: -2px; opacity: 1;"
>
<table
class="t-table--layout-fixed"
>
<colgroup>
<col
style="width: 120px;"
/>
<col
style="width: 150px;"
/>
<col
style="width: 120px;"
/>
<col
style="min-width: 80px;"
/>
<col
style="min-width: 80px;"
/>
<col
style="min-width: 80px;"
/>
<col
style="width: 120px;"
/>
</colgroup>
<tfoot
class="t-table__footer"
style="visibility: visible;"
>
<tr
class="t-tdesign__custom-footer-tr"
>
<td>
<b
style="font-weight: bold;"
>
表尾信息
</b>
</td>
<td />
<td>
footer-row-1
</td>
<td />
<td />
<td>
-
</td>
<td>
-
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div
class="t-table__pagination-wrap"
style="opacity: 1;"
Expand Down
Loading