Skip to content

Conversation

miownag
Copy link

@miownag miownag commented Oct 15, 2025

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

--

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

In uncontrolled scenarios, the children of Suggestion cannot know whether Suggestion is open or closed.

Actual scenario:
The enter key functionality of Cascader within Suggestion and that of Sender may overlap in practical use. For example, when the submitType of Sender is set to "enter", selecting an item in Suggestion will also trigger message sending. In such cases, users may need to change "open" to a controlled property and then use the open state to determine whether to allow message sending. As shown in the demo, after adding the "open" parameter, the open state can also be obtained in uncontrolled scenarios.

API implementation:
When retrieving childNode by executing children, additionally pass in open as mergedOpen:
children?.({ onTrigger, onKeyDown, open: mergedOpen });

Usage:
The children function parameter of Suggestion can be destructured to get the newly passed open, enabling certain controls as demonstrated in the demo.

<Suggestion>
      {({ onTrigger, onKeyDown, open }) => {
        return (
          <Sender
            value={value}
            onChange={(nextVal) => {
              if (nextVal === '/') {
                onTrigger();
              } else if (!nextVal) {
                onTrigger(false);
              }
              setValue(nextVal);
            }}
            // Sender will not submit when press enter if panel is open
            submitType={open ? false : 'enter'}
            onKeyDown={onKeyDown}
            placeholder="输入 / 获取建议"
          />
        );
      }}
</Suggestion>

📝 Change Log

Language Changelog
🇺🇸 English 🆕 Add an open field to the input parameters of the Suggestion component's children function.
🇨🇳 Chinese 🆕 Suggestion的children函数入参新增open字段。

Copy link
Contributor

github-actions bot commented Oct 15, 2025

Preview is ready

Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 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

Summary of Changes

Hello @miownag, 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 introduces a significant enhancement to the Suggestion component by providing its open state directly to its children. This change empowers developers to build more robust and context-aware user interfaces, especially in uncontrolled scenarios where the visibility of the suggestion panel needs to influence the behavior of nested components, thereby improving interaction predictability and user experience.

Highlights

  • New Feature: Expose 'open' state to Suggestion's children: The Suggestion component now passes its open state to its children function. This allows child components to react to whether the suggestion panel is open or closed, particularly useful in uncontrolled scenarios.
  • Enhanced Control for Uncontrolled Scenarios: This change addresses a limitation where children of Suggestion could not determine its open/closed status. A practical example is preventing a Sender component from submitting on 'enter' when the Suggestion panel is active, avoiding overlapping functionality.
  • API Update: The children prop of the Suggestion component now accepts an additional parameter open in its function signature: ({ onTrigger, onKeyDown, open }) => ReactElement.
  • New Demo and Documentation: A new demo (open.tsx) and corresponding documentation (open.md) have been added to illustrate how to utilize the newly exposed open state within the Suggestion component's children.
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.

@dosubot dosubot bot added the enhancement New feature or request label Oct 15, 2025
Copy link

@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 introduces a valuable feature by exposing the open state to the Suggestion component's children. This is particularly useful for uncontrolled components, as demonstrated in the new demo. The implementation is clean, and it's great to see it accompanied by documentation updates and tests. I have one minor suggestion to improve code clarity in the new demo file.

Comment on lines +1 to +7
import { Sender, Suggestion } from '@ant-design/x';
import type { GetProp } from 'antd';
import React from 'react';

type SuggestionItems = Exclude<GetProp<typeof Suggestion, 'items'>, () => void>;

const suggestions: SuggestionItems = [

Choose a reason for hiding this comment

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

medium

The way SuggestionItems is typed is a bit complex and can be simplified. The SuggestionItem type is exported and can be imported directly. This avoids using GetProp and Exclude, making the code clearer and more maintainable.

import { Sender, Suggestion } from '@ant-design/x';
import React from 'react';
import type { SuggestionItem } from '..';

const suggestions: SuggestionItem[] = [

Copy link

codecov bot commented Oct 15, 2025

Bundle Report

Changes will increase total bundle size by 2.32kB (1.71%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antdx-array-push 138.57kB 2.32kB (1.71%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.min.js 2.32kB 138.57kB 1.71%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant