Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 显示所有选中节点(包括父节点) #2233

Open
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

LuyangFE
Copy link
Contributor

@LuyangFE LuyangFE commented May 11, 2024

English Template / 英文模板

  • 我已阅读并遵循了贡献文档中的PR指南.

PR类型 (请至少选择一个)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR 描述

Fixes #
feature 在Tree组件中新增了bothParents属性,用来在多选时,返回所有子节点时同时返回父节点
img_v3_02ap_0639f79c-b9b8-4f64-a744-2a9c5febc77g

更新日志

🇨🇳 Chinese

  • Fix: 修复 ...

🇺🇸 English

  • Fix: fix ...

检查清单

  • 已增加测试用例或无须增加
  • 已补充文档或无须补充
  • Changelog已提供或无须提供

其他要求

  • 本条 PR 不需要纳入 Changelog

附加信息

img_v3_02ap_0639f79c-b9b8-4f64-a744-2a9c5febc77g

@LuyangFE LuyangFE changed the base branch from main to release May 11, 2024 14:51
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@YyumeiZhang YyumeiZhang self-requested a review May 13, 2024 03:06
@@ -2287,6 +2287,7 @@ import { IconFixedStroked, IconSectionStroked, IconAbsoluteStroked, IconInnerSec
| autoExpandParent | 是否自动展开父节点,默认为 false,当组件初次挂载时为 true | boolean | false | 0.34.0 |
| autoExpandWhenDragEnter | 是否允许拖拽到节点上时自动展开改节点 | boolean | true | 1.8.0 |
| blockNode | 行显示节点 | boolean | true | - |
| bothParents | 多选时,显示所有选中节点(包括父节点) | boolean | false | - |
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个模式融合到 checkRelation 中更好?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

可以在checkRelation中新增一个选项,命名为all吗?或者是你们提供一个名字?

const isMultiple = this._isMultiple();
const { keyMaps } = this.getProps();
const { keyEntities } = this.getStates();
if (this.getProp('treeDataSimpleJson')) {
if (bothParents) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

我理解这种模式的处理应该在 notifyMultipleChange 中?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

确实是多选下的条件,稍后修改

@YyumeiZhang
Copy link
Collaborator

还需要考虑的点

  1. 受控时候,在 getDerivedState 部分计算 checkedKey,halfCheckedKey部分的计算(getDerivedState -> calcCheckedKeys->findDescendantKeys) 中是否需要计算 descendantKeys, 在父子节点作为 onChange 的 value 传出的话,看上去不需要再次计算 descendKeys, 省下此计算的性能)
  2. 英文文档 路径 content/navigation/tree/index-en-US.md
  3. 测试用例补充
  4. 方便的话,在 TreeSelect中补充同样的功能?

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.

None yet

2 participants