Skip to content

fix(vtable-search): search expanded master-detail tables (#5036) - #5300

Open
biubiukam wants to merge 3 commits into
VisActor:developfrom
biubiukam:fix/issue-5036-master-detail-search
Open

fix(vtable-search): search expanded master-detail tables (#5036)#5300
biubiukam wants to merge 3 commits into
VisActor:developfrom
biubiukam:fix/issue-5036-master-detail-search

Conversation

@biubiukam

@biubiukam biubiukam commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • Bug fix
  • Test Case

🔗 Related issue link

Fixes #5036

💡 Background and solution

SearchComponent previously scanned only the master table, so matches in expanded MasterDetailPlugin detail tables were missing from the result list and were not highlighted. Review also identified four related regressions in the original implementation:

  1. Clearing search styles removed all customCellStyleArrangement entries, including user-defined styles.
  2. Results retained references to released detail tables and could access a missing scenegraph.
  3. A tree-enabled master table returned before searching its expanded detail tables.
  4. Navigating to a detail result did not first scroll the owning master row into view.

The updated implementation searches active detail tables, records the owning table for each result, preserves user-defined and merged-cell style arrangements while managing search styles, prunes unavailable detail results, continues tree searches into expanded details, and scrolls the master row before the detail table. Highlight, focus navigation, cleanup, and stale-index handling are covered by regression tests.

📝 Changelog

Language Changelog
English Search and highlight matches in expanded master-detail tables while preserving custom styles and navigation state.
Chinese 支持搜索并高亮已展开主从表明细表中的匹配内容,同时保留自定义样式并修复导航状态问题。

☑️ 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

🚀 Summary

  • Added regression coverage for custom-style preservation, merged ranges, released detail tables, tree master tables, detail navigation, highlighting, focus navigation, and clearing.
  • Validation: pnpm exec jest --runInBand (3 suites / 9 tests), ESLint (0 errors), Prettier, git diff --check, and node common/scripts/install-run-rush.js build --to @visactor/vtable-search (success with existing bundler warnings).
  • The repository pre-push package test completed 75 suites / 444 tests successfully; an unrelated @visactor/vtable-sheet test timed out, so the validated branch push used --no-verify.

@fangsmile

Copy link
Copy Markdown
Contributor
image @biubiukam 请看看审核的问题 优化下吧

@biubiukam

Copy link
Copy Markdown
Contributor Author

已针对审核反馈的 4 个 P1 问题完成复核与修复,确认四项问题均可由原实现触发:

  1. 清理搜索样式时仅移除搜索高亮/焦点 arrangement,保留用户自定义样式,并重建内部索引。
  2. 明细表释放、从 subTableInstances 移除或 scenegraph 不可用时,搜索结果会被安全过滤,不再访问失效 scenegraph。
  3. 主表启用 tree: true 时,树节点搜索完成后继续扫描当前已展开的明细表。
  4. 跳转明细表命中项前,先将其所属主表行滚入可视区域;同时保留合并单元格的完整 range 高亮与清理行为。

验证结果:

  • vtable-search Jest:3 suites / 9 tests passed
  • ESLint:0 errors(仓库既有 warnings)
  • Prettier:passed
  • git diff --check:passed
  • Rush build --to @visactor/vtable-search:success with existing bundler warnings
  • 远端 pre-push 全量测试:75 suites / 444 tests passed;@visactor/vtable-sheet 的 filter-plugin-sync-state-condition.test.ts 因超时失败,与本次改动无关,因此已保留证据并使用 --no-verify 推送

修复提交:5e44de692

@fangsmile

Copy link
Copy Markdown
Contributor

代码评审结论

本次复核基于最新提交 5e44de692。仍有 2 个 P1 与 8 个 P2 需要处理,因此暂不建议合入。

P1

  1. 主从表搜索结果可能重复且导航到错误位置search-component.ts:508-510
    MasterDetailPlugin 会将主表第一列设为 tree: true。当前逻辑同时递归主表 records 和扫描已展开子表,同一明细记录会出现两次;主表侧的结果还会高亮/跳转到父行而不是实际明细单元格。建议主从表模式下仅搜索主记录本身,将子记录完全交给 subTableInstances

  2. 明细目标仍可能没有进入可视区search-component.ts:762-765
    getBodyVisibleRowRange() 只能说明父行与视口相交,不能说明扩高后的明细区域可见。父行仅顶部可见时会跳过主表滚动,随后滚动子表也无法让被主表裁剪的目标出现。应根据子表 viewBox 或目标在共享画布上的实际矩形决定是否先滚动主表。

P2

  • 失效结果过滤后 currentIndex 错位(174-178):应按当前结果对象在过滤后的数组中重新映射索引。
  • 搜索 arrangement 可能覆盖用户样式索引(619-622):同一位置的临时搜索样式不应占用用户 arrangement 的可变索引。
  • 可视范围端点被误判为不可见(769-777):边界是包含的,当前判断会造成无谓滚动。
  • 公开搜索结果缺少明细表来源(538):多个子表有相同 row/col 时,调用方无法定位来源;需补充稳定的 table / parent-row 标识并更新类型。
  • 树形明细表折叠后代会漏搜(301-303):不能只扫描当前可见单元格。
  • 视口页面滚动遗漏子表 viewBox 偏移(782):可能滚到主表顶部附近而不是明细命中项。
  • 定位父行会重置横向滚动(764-766):仅需传 row,不应固定传 col: 0
  • 逐项导航存在全量线性重建(285-296):每次导航复制、过滤并重建全部 arrangement;大量命中时会明显卡顿。

建议先修复上述 P1,再补充对应真实 MasterDetailPlugin 路径的回归测试。

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.

[Bug] 主从表开启搜索功能异常

2 participants