Skip to content

feat add onlyInputFocus #899

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dexter-cuijian
Copy link

@dexter-cuijian dexter-cuijian commented Jun 6, 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

Add a onlyInputFocus configuration to the sender component

Related issues: #893

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

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese

Summary by CodeRabbit

  • 新功能

    • 新增 onlyInputFocus 属性,可控制仅在点击输入框时才获取焦点。
  • 文档

    • 更新 API 文档,补充 onlyInputFocus 属性说明。

Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

📝 Walkthrough

Walkthrough

本次更新在 Sender 组件中引入了新的布尔属性 onlyInputFocus,并相应调整了点击内容区域时的焦点行为。只有当点击输入框本身时才会聚焦输入框,其他区域点击不会改变焦点。相关文档也同步更新说明。

Changes

文件/分组 变更摘要
components/sender/index.tsx 新增 onlyInputFocus 属性,调整内容区域点击事件处理逻辑
components/sender/index.zh-CN.md 文档新增 onlyInputFocus 属性说明,默认值为 false

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Sender
    participant InputBox

    User->>Sender: 点击内容区域
    alt onlyInputFocus = true 且点击非输入框
        Sender-->>User: 阻止默认行为,不聚焦
    else
        Sender->>InputBox: 聚焦输入框
    end
Loading

Poem

小兔写代码,聚焦有妙招,
只点输入框,别处不打扰。
新增小参数,文档同步好,
体验更精准,大家齐欢笑!
(⁎⁍̴̛ᴗ⁍̴̛⁎)


📜 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 8dcdedd and 2dd8d1c.

📒 Files selected for processing (2)
  • components/sender/index.tsx (3 hunks)
  • components/sender/index.zh-CN.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/sender/index.tsx
  • components/sender/index.zh-CN.md
✨ 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.
    • 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 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
Contributor

github-actions bot commented Jun 6, 2025

Prepare preview

@dosubot dosubot bot added the enhancement New feature or request label Jun 6, 2025
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: 0

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

49-49: 改善属性描述的清晰度

当前的描述"是否前缀mousedown触发输入框聚焦"有些模糊,可能导致理解歧义。建议修改为更清晰的描述。

-| prefixNoFocus | 是否前缀mousedown触发输入框聚焦 | boolean | false | - |
+| prefixNoFocus | 点击前缀区域时是否阻止输入框获得焦点 | boolean | false | - |
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aae1337 and 0c352b8.

📒 Files selected for processing (3)
  • components/sender/demo/_semantic.tsx (1 hunks)
  • components/sender/index.tsx (3 hunks)
  • components/sender/index.zh-CN.md (1 hunks)
🔇 Additional comments (4)
components/sender/demo/_semantic.tsx (1)

52-52: 演示用法正确

在语义化演示中正确使用了 prefixNoFocus 属性,与前缀按钮配合使用,能够有效展示该功能的效果。

components/sender/index.tsx (3)

79-79: 接口定义正确

新增的 prefixNoFocus 布尔属性定义符合预期,类型声明准确。


128-128: 属性解构实现正确

正确地从 props 中解构了 prefixNoFocus 属性。


271-274: 功能实现逻辑正确且健壮

实现逻辑清晰正确:

  • 使用 closest() 方法检查点击目标是否在前缀元素内,能够处理前缀元素的子元素点击
  • 在满足条件时正确调用 preventDefault() 并提前返回,阻止输入框获得焦点
  • 可选链操作符的使用提供了类型安全保障

@kimteayon
Copy link
Collaborator

有点不够通用 不只是前缀吧 可以直接改成如果不是点击input输入都可以不 focus 如果某些actuons需要focus可以通过senderRef.current.focus设置

@dexter-cuijian
Copy link
Author

dexter-cuijian commented Jun 10, 2025

有点不够通用 不只是前缀吧 可以直接改成如果不是点击input输入都可以不 focus 如果某些actuons需要focus可以通过senderRef.current.focus设置

u are right

@dexter-cuijian dexter-cuijian changed the title feat add prefixNoFocus feat add onlyInputFocus Jun 16, 2025
@kimteayon
Copy link
Collaborator

onlyInputFocus 这个配置就不要了吧 默认就input可被 focus 😁

@kimteayon kimteayon enabled auto-merge (squash) June 20, 2025 10:20
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.

2 participants