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

Merged
merged 2 commits into from
Jun 7, 2025

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

tdesign-react-demo

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

commit: fb11d6d

Copy link
Contributor

github-actions bot commented May 19, 2025

完成

@RylanBot RylanBot merged commit 55e4f2d into develop Jun 7, 2025
9 checks passed
@RylanBot RylanBot deleted the fix/select/multiple branch June 7, 2025 16:54
@github-actions github-actions bot mentioned this pull request Jun 13, 2025
16 tasks
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