Skip to content

Conversation

@RylanBot
Copy link
Collaborator

@RylanBot RylanBot commented Sep 20, 2025

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

Tencent/tdesign-react#3828

💡 需求背景和解决方案

  • 将 Vue 端使用的新版 tree/tree-node 中部分逻辑同步到 React 端使用的旧版 tree-v1/tree-node
  • 新旧版本统一确保 tree-node-model 返回的 disabled 对应真实的 UI 状态

📝 更新日志

  • fix(Tree): 修复 TreeNodeModel 中的 disabled 与 UI 状态不同步的问题

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@tdesign-bot
Copy link
Collaborator

tdesign-bot commented Sep 20, 2025

TDesign Component Repositories CI Test Open

Component Lint Test Build Preview
tdesign-vue 👀
tdesign-vue-next 👀
tdesign-react 👀
tdesign-web-components 👀
tdesign-mobile-vue 👀
tdesign-mobile-react 👀

@RylanBot RylanBot force-pushed the rylan/fix/tree/checkAll branch 2 times, most recently from caff224 to a32c8bb Compare September 22, 2025 03:43
@RylanBot RylanBot force-pushed the rylan/fix/tree/checkAll branch 3 times, most recently from 4e0f771 to 4f19623 Compare September 23, 2025 11:33
@RylanBot RylanBot force-pushed the rylan/fix/tree/checkAll branch from 4f19623 to 2fbc1cd Compare September 23, 2025 11:56
@RylanBot RylanBot force-pushed the rylan/fix/tree/checkAll branch from 3d02c71 to de15c02 Compare September 23, 2025 19:53
@RylanBot RylanBot force-pushed the rylan/fix/tree/checkAll branch from de15c02 to 1cf5ff9 Compare September 23, 2025 20:04
@RylanBot RylanBot force-pushed the rylan/fix/tree/checkAll branch from 07ba2b8 to 9133257 Compare September 23, 2025 20:50
@RylanBot RylanBot requested a review from Copilot September 25, 2025 09:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the disabled state logic for Tree components by synchronizing disabled state management between the Vue and React versions. The changes ensure that the TreeNodeModel's disabled property correctly reflects the actual UI state.

  • Refactors disabled state logic with proper priority handling (Tree config > checkStrictly > manual > node data > disableCheck)
  • Adds a new disableManually property to track manual disabled state changes
  • Updates the TreeNodeModel to expose the disabled property for better state synchronization

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
js/tree/tree-node.ts Refactored disabled state logic with new priority system and manual state tracking
js/tree-v1/types.ts Added disableCheck option to TreeStoreOptions interface
js/tree-v1/tree-node.ts Applied same disabled state enhancements as the main tree implementation
js/tree-v1/tree-node-model.ts Added disabled property to exposed TreeNodeModel properties

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

tree: TreeStore,
data?: TypeTreeNodeData,
parent?: TreeNode,
parent?: TreeNode
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The trailing comma was removed from the parameter list. For consistency with the codebase and modern TypeScript practices, consider keeping the trailing comma.

Suggested change
parent?: TreeNode
parent?: TreeNode,

Copilot uses AI. Check for mistakes.


if (!checkStrictly && parent?.isDisabled()) return true;

if (typeof this.disableManually === 'boolean') return this.disableManually;
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The condition should check for strict boolean types to ensure type safety. Consider using this.disableManually !== null instead to be more explicit about the intention.

Copilot uses AI. Check for mistakes.


if (!checkStrictly && parent?.isDisabled()) return true;

if (typeof this.disableManually === 'boolean') return this.disableManually;
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The condition should check for strict boolean types to ensure type safety. Consider using this.disableManually !== null instead to be more explicit about the intention.

Copilot uses AI. Check for mistakes.

Comment on lines +1365 to +1370
public setDisabled(disabled: null | boolean) {
if (!this.tree.config.checkStrictly && this.parent?.isDisabled()) return;
// 当 disabled 为 null 时,恢复为默认的禁用逻辑,而非通过设置强制指定
this.disableManually = disabled;
this.update();
this.updateChildren();
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The method silently returns when the parent is disabled and checkStrictly is false. This could be confusing for API consumers. Consider throwing an error or returning a boolean to indicate success/failure.

Suggested change
public setDisabled(disabled: null | boolean) {
if (!this.tree.config.checkStrictly && this.parent?.isDisabled()) return;
// 当 disabled 为 null 时,恢复为默认的禁用逻辑,而非通过设置强制指定
this.disableManually = disabled;
this.update();
this.updateChildren();
public setDisabled(disabled: null | boolean): boolean {
if (!this.tree.config.checkStrictly && this.parent?.isDisabled()) return false;
// 当 disabled 为 null 时,恢复为默认的禁用逻辑,而非通过设置强制指定
this.disableManually = disabled;
this.update();
this.updateChildren();
return true;

Copilot uses AI. Check for mistakes.

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.

2 participants