-
-
Notifications
You must be signed in to change notification settings - Fork 720
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
base: main
Are you sure you want to change the base?
feat add onlyInputFocus #899
Conversation
📝 WalkthroughWalkthrough本次更新在 Sender 组件中引入了新的布尔属性 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Sender
participant InputBox
User->>Sender: 点击内容区域
alt onlyInputFocus = true 且点击非输入框
Sender-->>User: 阻止默认行为,不聚焦
else
Sender->>InputBox: 聚焦输入框
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
📒 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()
并提前返回,阻止输入框获得焦点- 可选链操作符的使用提供了类型安全保障
有点不够通用 不只是前缀吧 可以直接改成如果不是点击input输入都可以不 focus 如果某些actuons需要focus可以通过senderRef.current.focus设置 |
u are right |
onlyInputFocus 这个配置就不要了吧 默认就input可被 focus 😁 |
中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
Add a
onlyInputFocus
configuration to the sender componentRelated issues: #893
💡 Background and Solution
📝 Change Log
Summary by CodeRabbit
新功能
onlyInputFocus
属性,可控制仅在点击输入框时才获取焦点。文档
onlyInputFocus
属性说明。