Skip to content

feat(vtable): auto-merge rectangular body multi-ranges - #5320

Open
Rui-Sun wants to merge 2 commits into
developfrom
codex/oncall-409732aa860f6e669014eacf1f037598
Open

Rui-Sun wants to merge 2 commits into
developfrom
codex/oncall-409732aa860f6e669014eacf1f037598

Conversation

@Rui-Sun

@Rui-Sun Rui-Sun commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • New feature
  • TypeScript definition update
  • Test Case

🔗 Related issue link

None.

💡 Background and solution

Add opt-in select.autoMergeRanges (default false) to merge adjacent or overlapping ordinary body selections when their connected union fills a rectangle. L-shaped, holed and disconnected selections retain their separate ranges. Header, row-series and frozen-partition selections are excluded.

selectCells evaluates the complete batch after per-range normalization and deduplication, including when the final input range is a duplicate. Ctrl selection and drag selection use the same merge routine. Selection borders and selected_cell payloads reflect the final ranges.

const table = new ListTable({
  // ...existing options
  select: { autoMergeRanges: true }
});

📝 Changelog

Language Changelog
English Add optional rectangular multi-range auto-merge for body selections; existing behavior remains the default.
Chinese 新增可选的 body 多选区矩形自动合并能力,默认选择行为不变。

Validation

Regression coverage includes disabled behavior, adjacent/overlapping rectangles, L-shapes, holes, disconnected ranges, duplicate final ranges, Ctrl/event behavior, drag selection and frozen boundaries. Host validation details are recorded below. Product Electron tests must run in CI before review/merge; this remains a Draft PR.

☑️ Self-Check before Merge

  • 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

Supersedes #5319 with the same implementation commit, submitted from a branch in this repository so repository CI secrets are available.

Runner validation

  • Targeted Rush install and build passed; scope, diff and test-file checks passed.
  • NOT RUN: product Jest/Electron tests; this runner has no xvfb-run/headless display.
  • Draft only: run the added tests and full product suite in CI before review/merge.

Upstream CI verification

@Rui-Sun
Rui-Sun marked this pull request as ready for review September 29, 2026 07:52

@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.

审查冻结版本的多选区合并实现及选择状态调用链;发现表头仅选 body 模式下由表头交互产生的范围被误当普通 body 范围合并。既有讨论为空。

验证:阅读冻结 diff、选区状态、表头选择投影、场景图重建及公开配置契约;Node 标准库最小复现验证相邻表头投影两范围均被判为可合并,且连通并铺满外接矩形;未运行工程测试。

限制:冻结源码未安装依赖;未运行 Jest/Electron、完整工程测试或浏览器视觉回归。;仅运行 Node 标准库的源码条件简化复现,确认表头投影范围符合资格与矩形合并条件;未在真实 ListTable 环境执行该交互。;当前任务无 Checks/Actions/commit statuses 权限,未独立核验 PR 文本提及的 CI 状态。

状态:completed

range,
normalizedRange: normalizeRange(range)
}));
const eligibleRanges = indexedRanges.filter(range => isMainBodyRange(range.normalizedRange, table));

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] 排除由表头交互投影出的 body 选区

当 select: { headerSelectMode: 'body', autoMergeRanges: true } 且没有额外冻结分区时,按 Ctrl 依次点击相邻两列表头,updateSelectPosition 会把每次表头选择投影成 { start: { col, row: columnHeaderLevelCount }, end: { col, row: rowCount - 1 }, skipBodyMerge: true }。这里仅根据投影后的坐标判断资格,两段范围均被当作普通 body 区域,并且恰好拼成矩形,于是合为一个选区;getSelectedCellRanges()、边框和后续选区事件都丢失了两次表头选择各自的范围。PR 声明表头选区不参与归并,但只检查 getCellLocation 无法区分由表头触发的 body 投影与普通 body 选择;需要保留选区来源再过滤。

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.

1 participant