-
Notifications
You must be signed in to change notification settings - Fork 263
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
fix(searchbar): 修复 clear 时未触发 change 的问题 #2262
Conversation
Walkthrough此次更改主要涉及将 Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2262 +/- ##
==========================================
+ Coverage 85.78% 85.87% +0.08%
==========================================
Files 217 217
Lines 22783 22784 +1
Branches 2481 2492 +11
==========================================
+ Hits 19545 19566 +21
+ Misses 3233 3213 -20
Partials 5 5 ☔ View full report in Codecov by Sentry. |
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
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- src/packages/searchbar/tests/searchbar.spec.tsx (2 hunks)
- src/packages/searchbar/demos/h5/demo7.tsx (1 hunks)
- src/packages/searchbar/demos/taro/demo7.tsx (1 hunks)
- src/packages/searchbar/searchbar.taro.tsx (2 hunks)
- src/packages/searchbar/searchbar.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
- src/packages/searchbar/demos/h5/demo7.tsx
Additional comments not posted (4)
src/packages/searchbar/demos/taro/demo7.tsx (1)
8-8
: 代码简化了onChange
处理函数,直接使用箭头函数更新状态,这种做法使得代码更加简洁明了。src/packages/searchbar/__tests__/searchbar.spec.tsx (1)
33-44
: 新增的测试用例 "Search clear & change" 验证了清除搜索输入框时触发变更事件的功能,符合 PR 的目标。src/packages/searchbar/searchbar.tsx (1)
32-32
: 对onChange
属性的更改,允许事件参数可选,这增加了组件的灵活性,使得在程序触发变更时也能够调用此函数。src/packages/searchbar/searchbar.taro.tsx (1)
32-32
: 与常规 React 版本类似,对onChange
属性的更改,允许事件参数可选,这为组件增加了灵活性。
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.
可以先看下组件受控非受控上的实现。
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit
新功能
Searchbar
组件重命名为SearchBar
,并更新了相应的测试用例。改进
SearchBar
组件的onChange
事件处理程序。onChange
函数签名更新为可接受可选的event
参数,并在某些条件下调用onChange('')
。修复
Demo7
组件中的change
函数,直接使用简化的箭头函数更新value
状态。