Skip to content

feat: 给表格增加一个配置项 - #5335

Open
rubbishmaker wants to merge 6 commits into
VisActor:developfrom
rubbishmaker:feat/add-drop-cloumn-config@20260930
Open

rubbishmaker wants to merge 6 commits into
VisActor:developfrom
rubbishmaker:feat/add-drop-cloumn-config@20260930

Conversation

@rubbishmaker

Copy link
Copy Markdown

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Site / documentation update
  • Demo update
  • Workflow
  • Chore
  • Release
  • Other (about what?)

🔗 Related issue link

#4809

💡 Background and solution

📝 Changelog

增加一个配置项realtime,用于控制表格的resize行为。默认为true,与当前行为保持一致,为false时不会实时渲染,拖拽中 :只累积偏移量pendingDelta + 移动指示线,不重排列宽/行高,松开时 :一次性把累计偏移应用到真实列宽/行高
| ---------- | --------- |
| 🇺🇸 English | |
| 🇨🇳 Chinese | |

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@fangsmile

fangsmile commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

有两处阻塞性问题需要修正后再合并:

  1. 非实时模式会把整段 pendingDeltaX 一次传入 min/max 约束,当前按“当前宽度离哪个边界更近”选择边界,可能产生反向 resize。例如宽度 180、minWidth=100、maxWidth=200,向左累计拖动 100px 后目标为 80,但代码会取 maxWidth - widthCache = 20,最终反而扩到 200。应按目标值的越界方向 clamp,并补跨越 min/max 的非实时回归用例。

  2. adaptive 模式重复扣减累计位移。rightColWidth 已是 rightColWidthCache - detaX,随后又用 rightColWidth - detaX 判断 limitMinWidth。相邻列宽 150、最小宽 10、累计右拖 80px 时,右列应为 70,但当前会把位移错误截成 60px,导致最终尺寸与指示线终点、实时模式不一致。行高路径存在相同问题,需要同步修正并补测试。

rubbishmaker and others added 2 commits October 10, 2026 15:28
- Clamp column width by the target value's out-of-bounds direction so
  non-realtime mode no longer reverse-resizes to the far min/max boundary
  when the whole pending delta is applied at once.
- Stop double-subtracting the accumulated delta on the adaptive neighbor
  column/row, keeping the final size consistent with the indicator line
  and realtime mode.
- Add deterministic regression cases for non-realtime min clamp and
  adaptive neighbor column/row resize.
- Mount the resize-realtime example toggle inside the table root element
  so it no longer leaks onto other demos.

@visactor-review-bot visactor-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发现 1 个需要修复的问题,见行内评论。

Comment thread packages/vtable/src/state/resize/update-resize-column.ts
@github-actions github-actions Bot added the test label Oct 12, 2026

@visactor-review-bot visactor-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发现 1 个需要修复的新问题,见行内评论。

const colBaseX = getColX(col, this.table, isRightFrozen);
const delta = previewDeltaX ?? 0;
// 非实时响应模式下指示线基于当前列右边界+累计偏移量渲染
const colX = isRightFrozen ? colBaseX - delta : colBaseX + delta;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 非实时拖拽预览应按最终尺寸约束指示线

当 resize.realtime=false 且拖拽越过 minWidth/maxWidth(或 adaptive 模式下相邻列的最小宽度)时,这里直接用未约束的 pendingDeltaX 移动指示线,标签也显示未约束的宽度;松手后 applyColumnResizeDelta 才执行约束。例如列宽 180、minWidth=100,左拖 100px,指示线和标签预览 80px,最终列宽却是 100px,松开时边界跳回 20px。行高预览的 pendingDeltaY 与 limitMinHeight 同样存在此问题。建议在绘制预览时复用与提交相同的有效位移计算,使指示线和标签对应最终可应用的尺寸。这不同于已有讨论中提交时反向 clamp 或 adaptive 位移重复扣减:即使最终尺寸计算正确,预览仍会失真。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

In non-realtime resize mode the indicator line and label previewed the raw
unconstrained pendingDelta, so dragging past min/max (or an adaptive neighbor
limit) showed a size that jumped on mouse up. Reuse the same effective-delta
computation as commit via a dry-run path so the preview matches the final size.

Add a deterministic visual regression case for the column preview clamp.

@visactor-review-bot visactor-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

未发现可确认的新问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants