Skip to content

fix(Select): prevent event triggering when checkAll is disabled #3563

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

RylanBot
Copy link
Collaborator

@RylanBot RylanBot commented May 19, 2025

🤔 这个 PR 的性质是?

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

🔗 相关 Issue

💡 需求背景和解决方案

禁用全选后仍会触发事件:

const options1 = [
  { label: "全选", checkAll: true, disabled: true },
   // ...
]
Jietu20250519-103010-HD.mp4

核心修改部分是:

const isDisabledCheckAll = (opt: TdOptionProps) => opt.checkAll && opt.disabled;
if (!multiple || currentOptions.some((opt) => !isSelectOptionGroup(opt) && isDisabledCheckAll(opt))) {
  return;
}

(其他部分是顺手优化了一下写法)

📝 更新日志

  • fix(Select): 修复 checkAll 设为 disabled 后依旧会触发全选的问题

  • 本条 PR 不需要纳入 Changelog

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

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

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

Copy link
Contributor

@Copilot 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 fixes an issue where the "checkAll" event in the Select component is still triggered even when the corresponding option is disabled. Key changes include:

  • Updating helper and hook files for improved type safety and code clarity.
  • Modifying the onCheckAllChange handler in the Select component to prevent triggering when a disabled checkAll option exists.
  • Refactoring inline type and function definitions to align with updated coding patterns.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/components/select/util/helper.ts Removed unused type imports and refined typing of ReactElement parameters.
packages/components/select/hooks/useOptions.ts Updated type definitions and state initialization for options handling.
packages/components/select/base/Select.tsx Introduced a check to avoid triggering events for disabled checkAll options and refactored inline helper functions.

Copy link

pkg-pr-new bot commented May 19, 2025

Open in StackBlitz

npm i https://pkg.pr.new/tdesign-react@3563

commit: dd00b8f

Copy link
Contributor

完成

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