Skip to content

Conversation

@QdabuliuQ
Copy link

@QdabuliuQ QdabuliuQ commented Jan 23, 2026

🤔 This is a ...

  • 🐞 Bug fix

🔗 Related Issues

issue: 56724

💡 Background and Solution

When both the optionRender and notFoundContent properties are set on the Cascader component, the search results are empty and notFoundContent does not take effect.

📝 Change Log

Language Changelog
🇺🇸 English Fix notFoundContent not working
🇨🇳 Chinese 修复 notFoundContent 不生效

Summary by CodeRabbit

发布说明

  • Bug Fixes

    • 修复搜索功能中无结果情况下的选项渲染逻辑,确保正确应用自定义渲染或显示默认标签。
  • Tests

    • 添加三个新测试用例,验证搜索无结果、结果显示和空选项列表时的行为表现。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 23, 2026

@QdabuliuQ is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @QdabuliuQ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug in the Cascader component where the notFoundContent prop was not correctly rendered when a custom optionRender function was also provided and the search yielded no results. The fix ensures that the component prioritizes displaying the notFoundContent message in empty states, providing a consistent user experience.

Highlights

  • Bug Fix: notFoundContent with optionRender: Corrected an issue in the Cascader component where notFoundContent was not displayed when optionRender was also used and search results were empty.
  • Conditional optionRender Application: Implemented a conditional check in src/OptionList/Column.tsx to prevent optionRender from being applied to the special __EMPTY__ option, ensuring notFoundContent takes precedence for empty states.
  • New Test Cases: Introduced new test cases in tests/search.spec.tsx to validate the proper rendering of notFoundContent when search results are empty or options are initially empty, both with and without optionRender.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Walkthrough

PR修改了Column组件中optionRender的条件渲染逻辑,使其仅在optionRender存在且选项值不为'EMPTY'时才应用自定义渲染,否则直接显示标签。并新增三个测试用例验证notFoundContent与optionRender的优先级。

Changes

Cohort / 文件(s) 改动摘要
optionRender条件渲染守卫
src/OptionList/Column.tsx
添加条件判断,仅当optionRender存在且选项值不为'EMPTY'时执行自定义渲染,否则渲染标签。防止sentinel值使用自定义渲染逻辑。
notFoundContent与optionRender交互测试
tests/search.spec.tsx
新增3个测试用例:验证无搜索结果时notFoundContent优先于optionRender展示、搜索结果存在时optionRender正常工作、选项数组为空时notFoundContent正确显示。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

🐰 哨兵值守护渲染路,
空值不走自定义途,
notFound优先展芳颜,
三个新测保周全,
逻辑清晰入云端!✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确总结了主要变更:修复optionRender在空搜索结果时的使用问题,与代码改动和PR目标完全相符。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a 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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug where notFoundContent was not displayed when optionRender was also used and search results were empty. The fix in src/OptionList/Column.tsx is correct and prevents optionRender from being called on the special empty option. The new tests in tests/search.spec.tsx are comprehensive, covering the fix, a positive case, and an edge case. I have one suggestion regarding the use of a magic string to improve code maintainability.

)}
<div className={`${menuItemPrefixCls}-content`}>
{optionRender ? optionRender(option) : label}
{optionRender && value !== '__EMPTY__' ? optionRender(option) : label}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this correctly fixes the bug, using the magic string __EMPTY__ makes the code less maintainable and more brittle. This string is also used in src/OptionList/List.tsx but is not shared. It would be better to define it as an exported constant in a shared location (e.g., alongside FIX_LABEL in this file) and use the constant in both places. This ensures consistency and makes the code easier to understand and refactor in the future.

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.

1 participant