Skip to content
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

Add autoSize property to Sender component #637

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

Conversation

Zhang-Wei-666
Copy link

@Zhang-Wei-666 Zhang-Wei-666 commented Mar 21, 2025

Fixes #635


For more details, open the Copilot Workspace session.

Summary by CodeRabbit

  • 新功能
    • 为文本输入区域添加了自动调整高度的功能,用户现在可以通过简单配置来设定最小行数和最大行数。
    • 新增的配置选项支持布尔值或对象形式,确保在不同输入量下都能获得最佳显示效果,同时保持现有功能的稳定性。

Copy link
Contributor

coderabbitai bot commented Mar 21, 2025

📝 Walkthrough

Walkthrough

此次 PR 在 Sender 组件中新增了 autoSize 属性,使输入区域能够根据内容动态调整高度。该属性支持传入布尔值或包含 minRowsmaxRows 的对象,并在组件内部传递给 InputTextArea 使用。更新内容涵盖了 Demo 展示文件、英文和中文文档以及核心组件实现代码,现有功能保持不变,仅增强了配置灵活性。

Changes

文件 变更说明
components/sender/demo/basic.tsx 在 Demo 组件中新增 autoSize 属性,配置为对象 { minRows: 2, maxRows: 6 }
components/sender/index.en-US.md, components/sender/index.zh-CN.md 更新文档,增加 autoSize 属性说明(支持布尔值或对象),默认值设为 { maxRows: 8 }
components/sender/index.tsx 更新 SenderProps 接口,新增可选属性 autoSize(类型为 `boolean

Sequence Diagram(s)

sequenceDiagram
    participant Demo as Demo组件
    participant Sender as Sender组件
    participant Input as InputTextArea组件

    Demo->>Sender: 传入 autoSize {minRows:2, maxRows:6}
    Sender->>Input: 调用 InputTextArea(autoSize)
Loading

Assessment against linked issues

Objective Addressed Explanation
支持传入 autoSize 属性 (#635)

Possibly related PRs

Suggested reviewers

  • YumoImer

Poem

嗨,我是跳跃的小兔子,
见到 autoSize 笑逐颜开,
输入框随意伸缩如梦幻,
min 与 max 拉出美丽舞台,
代码世界多彩有趣,
祝你每行代码都轻盈自在!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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

Prepare preview

Copy link

Walkthrough

This pull request introduces an autoSize property to the Sender component, allowing the height of the input area to automatically adjust based on content. The autoSize can be configured with minimum and maximum row settings, enhancing the flexibility of the component.

Changes

File Summary
components/sender/demo/basic.tsx Added autoSize property to Sender component demo with minRows and maxRows settings.
components/sender/index.en-US.md, components/sender/index.zh-CN.md Updated documentation to include autoSize property description.
components/sender/index.tsx Implemented autoSize property in Sender component, allowing configuration of minRows and maxRows.

@@ -114,6 +115,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
header,
onPaste,
onPasteFile,
autoSize = { maxRows: 8 },

Choose a reason for hiding this comment

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

Ensure that the default value for autoSize is correctly set and does not conflict with other properties or expected behaviors of the Sender component.

Copy link
Contributor

@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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d8c45e and 13562f4.

📒 Files selected for processing (4)
  • components/sender/demo/basic.tsx (1 hunks)
  • components/sender/index.en-US.md (1 hunks)
  • components/sender/index.tsx (3 hunks)
  • components/sender/index.zh-CN.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
components/sender/index.en-US.md

[uncategorized] ~56-~56: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...) => void | - | - | | autoSize | Height auto size feature, can be set to true | false or...

(AUTO_HYPHEN)

🪛 markdownlint-cli2 (0.17.2)
components/sender/index.en-US.md

56-56: Table column count
Expected: 5; Actual: 4; Too few cells, row will be missing data

(MD056, table-column-count)

🔇 Additional comments (5)
components/sender/demo/basic.tsx (1)

41-41: 非常好!示例演示了自适应高度功能

通过为 Sender 组件添加 autoSize 属性并设置 minRowsmaxRows 值,很好地展示了新增功能的使用方式。这使输入框可以根据内容自动调整高度,提升了用户体验。

components/sender/index.zh-CN.md (1)

57-57: 属性文档完整清晰,表格结构正确

autoSize 属性的文档说明非常清晰,包含了完整的类型定义和默认值,表格结构也符合规范,有助于用户理解和使用此功能。

components/sender/index.tsx (3)

77-77: 接口定义正确,使用可选参数

SenderProps 接口中 autoSize 属性的类型定义正确,使用可选参数(?)允许用户根据需求决定是否使用此功能。类型定义也与文档保持一致。


118-118: 默认值设置合理

autoSize 属性提供了默认值 { maxRows: 8 },这与文档中描述的默认值一致,并且提供了合理的初始体验。


313-313: 属性传递实现正确

正确地将 autoSize 属性传递给 InputTextArea 组件,替换了之前硬编码的值,实现了动态调整文本区域高度的功能。

@@ -53,6 +53,7 @@ Common props ref:[Common props](/docs/react/common-props)
| onChange | Callback when input value changes | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
| onCancel | Callback when click cancel button | () => void | - | - |
| onPasteFile | Callback when paste files | (firstFile: File, files: FileList) => void | - | - |
| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | { maxRows: 8 } | - |
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 21, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

表格缺少类型列,需要补充类型信息

当前 autoSize 属性的表格行缺少类型列的信息,这导致表格列数不一致,可能会影响文档渲染效果。

请将 autoSize 属性的表格行修改为以下内容:

-| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | { maxRows: 8 } | - |
+| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | boolean \| { minRows?: number; maxRows?: number } | { maxRows: 8 } | - |

另外,可以考虑将 "auto size" 修改为 "auto-size" 以保持一致的拼写规范。

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | { maxRows: 8 } | - |
| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | boolean \| { minRows?: number; maxRows?: number } | { maxRows: 8 } | - |
🧰 Tools
🪛 LanguageTool

[uncategorized] ~56-~56: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ...) => void | - | - | | autoSize | Height auto size feature, can be set to true | false or...

(AUTO_HYPHEN)

🪛 markdownlint-cli2 (0.17.2)

56-56: Table column count
Expected: 5; Actual: 4; Too few cells, row will be missing data

(MD056, table-column-count)

Copy link
Collaborator

Choose a reason for hiding this comment

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

少了 Version 列 辛苦加上

Copy link
Contributor

Choose a reason for hiding this comment

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

@kimteayon 您说得对,表格行缺少了 Version 列。实际上是因为缺少了 Type 列,导致后面的列都错位了。下面是修正后的完整表格行,包含了所有5列(Property、Description、Type、Default 和 Version):

| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | boolean \| { minRows?: number; maxRows?: number } | { maxRows: 8 } | - |

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.

希望 Sender 组件可以传入 autoSize
2 participants