Skip to content

fix(): 树形构件搜索过滤后全选问题修复#533

Merged
gdutzhendong merged 1 commit intoeasyops-cn:masterfrom
zxd123z:zhangxiaodi/DynamicV2
Mar 4, 2026
Merged

fix(): 树形构件搜索过滤后全选问题修复#533
gdutzhendong merged 1 commit intoeasyops-cn:masterfrom
zxd123z:zhangxiaodi/DynamicV2

Conversation

@zxd123z
Copy link
Contributor

@zxd123z zxd123z commented Mar 4, 2026

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

发布说明

  • Bug Fixes
    • 优化树形组件的数据处理逻辑,确保选中状态和数据同步更加准确可靠。

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

演练

BrickTree 组件内部逻辑改动,将树形数据检查、选择和状态派生的数据源从 defaultData 转换为 treeData,包括调整相关依赖数组和条件分支逻辑。

改动

内聚体 / 文件 摘要
树形组件数据源转换
bricks/presentational-bricks/src/brick-tree/BrickTree.tsx
用 treeData 替换 defaultData 处理键值检查、全选状态计算和依赖项,包括更新 getAllKeys() 调用、getAllCheckedState() 逻辑以及 onCheckAllChange 和 onCheck 事件处理。

预计代码审查工作量

🎯 2 (简单) | ⏱️ ~10 分钟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰地总结了主要变更:修复树形构件在搜索过滤后全选功能的问题,准确反映了代码改动的核心目的。
Description check ✅ Passed PR描述填充了大部分所需的检查项,正确标记了依赖检查和问题修复类别,但缺少具体的实现细节描述。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.82%. Comparing base (ae55a77) to head (45f1d8b).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #533   +/-   ##
=======================================
  Coverage   85.82%   85.82%           
=======================================
  Files        1113     1113           
  Lines       25759    25766    +7     
  Branches     4238     4238           
=======================================
+ Hits        22107    22114    +7     
  Misses       2778     2778           
  Partials      874      874           
Files with missing lines Coverage Δ
...presentational-bricks/src/brick-tree/BrickTree.tsx 86.50% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bricks/presentational-bricks/src/brick-tree/BrickTree.tsx (1)

488-495: ⚠️ Potential issue | 🟠 Major

onCheck 仍使用 defaultData,过滤场景下会把全选状态算错。

Line 491 和 Line 493 还在用 defaultData,会导致手动勾选后 allChecked/indeterminate 与当前过滤视图不一致,修复路径不完整。建议与上面 useEffect 的逻辑保持一致,统一使用 treeData

建议修改
-      if (!checkedNotRelevant) {
-        allChecked = defaultData.every((node) => checkedKeySet.has(node.key));
-      } else {
-        const allKeys = getAllKeys(defaultData);
-        allChecked = allKeys.every((key) => checkedKeySet.has(key));
-      }
+      if (!checkedNotRelevant) {
+        allChecked = getAllCheckedState(treeData, checkedKeySet);
+      } else {
+        const allKeys = getAllKeys(treeData);
+        allChecked = allKeys.every((key) => checkedKeySet.has(key));
+      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bricks/presentational-bricks/src/brick-tree/BrickTree.tsx` around lines 488 -
495, The onCheck handler computes allChecked using defaultData which causes
incorrect allChecked/indeterminate when a filter is active; change the logic in
the onCheck block (where checkedKeySet, checkedNotRelevant, getAllKeys and
allChecked are used) to mirror the useEffect logic and use treeData instead of
defaultData when determining which nodes to consider (i.e., if
checkedNotRelevant is false use treeData.every(...), otherwise use
getAllKeys(treeData) to compute allKeys) so the computed
allChecked/indeterminate aligns with the current filtered view.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@bricks/presentational-bricks/src/brick-tree/BrickTree.tsx`:
- Around line 488-495: The onCheck handler computes allChecked using defaultData
which causes incorrect allChecked/indeterminate when a filter is active; change
the logic in the onCheck block (where checkedKeySet, checkedNotRelevant,
getAllKeys and allChecked are used) to mirror the useEffect logic and use
treeData instead of defaultData when determining which nodes to consider (i.e.,
if checkedNotRelevant is false use treeData.every(...), otherwise use
getAllKeys(treeData) to compute allKeys) so the computed
allChecked/indeterminate aligns with the current filtered view.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

Run ID: b67bb97d-ad54-401d-936f-4c377595cb43

📥 Commits

Reviewing files that changed from the base of the PR and between b64384f and 45f1d8b.

📒 Files selected for processing (1)
  • bricks/presentational-bricks/src/brick-tree/BrickTree.tsx

@gdutzhendong gdutzhendong merged commit 5566922 into easyops-cn:master Mar 4, 2026
5 checks passed
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