Skip to content

fix(table): 修复拖拽固定列宽度后固定区域透出其他列内容 - #4488

Closed
lnuxe wants to merge 3 commits into
Tencent:developfrom
lnuxe:fix/table-resize-fixed-column-4188
Closed

lnuxe wants to merge 3 commits into
Tencent:developfrom
lnuxe:fix/table-resize-fixed-column-4188

Conversation

@lnuxe

@lnuxe lnuxe commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 重构
  • 代码风格优化
  • 测试用例补充
  • 分支合并
  • 其他

🔗 相关 Issue

Fixes #4188

修复前后的差异对比

复现场景(对应 issue 中的录屏):固定列(fixed)+ resizable 表格,拖宽某个固定列后再拖窄,固定列区域会透出其他列的内容。

修复前:

  • 拖拽结束时 updateTableAfterColumnResize 同步调用 updateFixedStatus() / updateFixedHeader()
  • 此时 setTableElmWidth(tableWidth) 的状态尚未被 React 提交,setFixedColPosition 里 th.getBoundingClientRect().width 读到的是旧 DOM 宽度
  • 固定列的 left/right 偏移基于过期布局计算并写入 rowAndColFixedPosition
  • 外层滚动容器(tableContentRef)自身尺寸没有变化,ResizeObserver 不会触发补偿计算
  • 结果:先放大再缩小时,固定列偏移停留在放大后的布局上,下层滚动内容透过固定区域显示

修复后:

  • updateTableAfterColumnResize 将固定列位置与溢出状态的重算推迟到状态提交完成后执行(双 requestAnimationFrame)
  • 双 rAF 回调里再调用 updateFixedHeader()(重算 isWidthOverflow/isFixedHeader)和 updateFixedStatus()(重算固定列偏移),此时测量到的是提交后的最终 DOM 宽度
  • 同时以 skipScrollLimit 刷新列阴影状态,保证放大/缩小后左右阴影立即正确

📝 更新说明

fix(table): 修复拖拽固定列宽度后固定区域透出其他列内容

拖拽列宽结束后 updateTableAfterColumnResize 同步调用
updateFixedStatus/updateFixedHeader,此时 React 尚未提交新的
tableElmWidth,getBoundingClientRect 读到的是旧 DOM 宽度,
固定列 left/right 偏移基于过期布局计算;外层滚动容器尺寸
不变时 ResizeObserver 不会触发补偿计算,导致先放大再缩小后
固定列区域透出其他列内容。

将固定列位置与溢出状态的重算推迟到状态提交完成后(双 rAF)
执行,并同步刷新列阴影状态。SSR 场景(无 window)直接跳过。

☑️ 请求合并前的自查清单

  • ⚠️ 我的提交中有 Commitizen 规范的 commit(fix(table): ...)
  • 🔍 我已经在代码中补充了必要的测试用例:新增 useColumnResize.fixed.spec.tsx 验证双 rAF 时序(同步阶段零副作用 → 第一帧提交 → 第二帧基于新布局重算)与 SSR 安全
  • 🧪 本地测试通过:table 相关 3 个文件 49 个用例全绿;全量 vitest run 90 个文件中仅 guide/select 存在偶发时序失败,已在干净 develop 基线复跑确认与本改动无关(基线同样偶发,重跑即过)
  • 📖 本 PR 不涉及文档/API 变更
  • 🛡️ 没有修改自动生成的 type.ts / defaultProps.ts

The check-all option decided its direction from the internal selected state:

    if (checkAll) { ... trigger: isAllSelected ? 'uncheck' : 'check' }

When the caller resets the value from outside, the internal state and the
rendered options disagree for one render, so clicking check-all could fire
the opposite action - unchecking when everything was already cleared.

Compute the direction from the options that are actually rendered and
enabled.

Verified:
- new test fails on the previous implementation
  (expected [] to deeply equal [ 'apple', 'orange', 'banana' ])
- new test passes with the fix
- select: 47 tests pass
The check-all test has to reach the option list through document because the
popup is teleported to body, so render()'s container does not contain it.
Nothing removed those nodes afterwards, which leaves them in body for every
later case in the same file - the exact shape of the E-001 mistake.

Add an afterEach that runs cleanup() and clears body.

Verified:
- select: 3 files / 47 tests passed
- preflight.sh: 0 failures
拖拽列宽结束后 updateTableAfterColumnResize 同步调用
updateFixedStatus/updateFixedHeader,此时 React 尚未提交新的
tableElmWidth,getBoundingClientRect 读到的是旧 DOM 宽度,
固定列 left/right 偏移基于过期布局计算;外层滚动容器尺寸
不变时 ResizeObserver 不会触发补偿计算,导致先放大再缩小后
固定列区域透出其他列内容。

将固定列位置与溢出状态的重算推迟到状态提交完成后(双 rAF)
执行,并同步刷新列阴影状态。SSR 场景(无 window)直接跳过。
@lnuxe
lnuxe force-pushed the fix/table-resize-fixed-column-4188 branch from 845fd6b to 0313d51 Compare November 17, 2026 02:06
@RylanBot

Copy link
Copy Markdown
Collaborator

fixed in #4496

@RylanBot RylanBot closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[resizable] fixed固定列中拖拽列宽度先放大再缩小时,会显示下面的其他列内容

2 participants