Skip to content

feat: combine search props #646

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 13 commits into from
Jun 24, 2025

Conversation

EmilyyyLiu
Copy link
Contributor

@EmilyyyLiu EmilyyyLiu commented Jun 16, 2025

ant-design/ant-design#33482
FRC: ant-design/ant-design#53978

Summary by CodeRabbit

  • 新功能

    • 支持通过 showSearch 配置对象统一设置搜索相关属性,简化 TreeSelect 组件的搜索配置方式。
    • 新增 useSearchConfig Hook,用于统一处理搜索配置,提升性能和可维护性。
  • 重构

    • 将原有多个搜索相关属性合并为 showSearch 配置项,原有属性已标记为废弃但仍保持兼容。
  • 测试

    • 新增用例,验证 showSearch 配置对象与旧用法在搜索、过滤等场景下的兼容性和一致性。

Copy link

vercel bot commented Jun 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tree-select ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2025 1:49am

Copy link

coderabbitai bot commented Jun 16, 2025

"""

Walkthrough

本次变更对 TreeSelect 组件的搜索相关 API 进行了重构。引入了新的 SearchConfig 接口,将原本分散的搜索相关属性合并为一个配置对象,并通过 showSearch 支持布尔值或配置对象两种形式。内部逻辑和测试用例也相应调整,兼容旧用法。

Changes

文件/分组 变更摘要
src/TreeSelect.tsx 引入 SearchConfig 接口;TreeSelectProps 支持 showSearch 为布尔或配置对象;原有搜索相关属性标记为废弃,内部逻辑统一使用 showSearch
src/hooks/useSearchConfig.ts 新增 useSearchConfig Hook,统一解析和合并搜索配置,兼容新旧用法。
tests/Select.spec.tsx 新增多组测试,验证 showSearch 及相关属性在新旧用法下的一致性和功能正确性。
package.json 更新依赖 @rc-component/select 版本号从 ~1.0.7~1.1.0

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TreeSelect
    participant useSearchConfig
    participant BaseSelect

    User->>TreeSelect: 传入 showSearch (布尔/对象) 及/或旧搜索属性
    TreeSelect->>useSearchConfig: 合并 showSearch 和旧属性
    useSearchConfig-->>TreeSelect: 返回 mergedShowSearch, searchConfig
    TreeSelect->>BaseSelect: 传递 mergedShowSearch, searchConfig
    User->>TreeSelect: 输入搜索内容
    TreeSelect->>BaseSelect: 触发 onSearch、过滤树节点等逻辑
Loading

Suggested reviewers

  • zombieJ

Poem

小兔子跳进树丛间,
搜索新法巧实现。
showSearch 一键变,
配置对象真方便。
旧貌新颜皆兼容,
代码整洁笑开颜!
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

tests/Select.spec.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f015c60 and 7203a7f.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • tests/Select.spec.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Select.spec.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/Select.spec.tsx (1)

713-838: 测试用例操作未使用 act,可能产生异步警告

fireEvent.change 后组件内部会触发 setState,React Testing Library 建议包裹在 act 中,以避免 “state update on unmounted component” 之类的异步告警。虽然当前 CI 可能未报错,但长期来看易埋隐患。

-import { render, fireEvent } from '@testing-library/react';
+import { render, fireEvent, act } from '@testing-library/react';
 ...
- fireEvent.change(legacyInput, { target: { value: '2' } });
- fireEvent.change(currentInput, { target: { value: '2' } });
+ await act(async () => {
+   fireEvent.change(legacyInput, { target: { value: '2' } });
+   fireEvent.change(currentInput, { target: { value: '2' } });
+ });
src/TreeSelect.tsx (1)

746-749: searchConfig 展开顺序可能掩盖配置

{...searchConfig} 位于 searchValueonSearch 之前,后两者会覆盖同名字段。当前实现依赖这种覆盖逻辑,但可读性较弱,后续维护者易误调顺序导致行为变化。
建议显式剔除 searchValueonSearch 后再展开,或增加注释说明覆盖意图。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51d13d2 and 148a60e.

📒 Files selected for processing (3)
  • src/TreeSelect.tsx (6 hunks)
  • src/hooks/useSearchConfig.ts (1 hunks)
  • tests/Select.spec.tsx (2 hunks)

Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.83%. Comparing base (51d13d2) to head (7203a7f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #646   +/-   ##
=======================================
  Coverage   99.83%   99.83%           
=======================================
  Files          16       17    +1     
  Lines         593      602    +9     
  Branches      184      186    +2     
=======================================
+ Hits          592      601    +9     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​rc-component/​select@​1.0.7 ⏵ 1.1.078 +110010095 +2100

View full report

@zombieJ zombieJ merged commit 93d450b into react-component:master Jun 24, 2025
9 checks passed
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