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

fix(searchbar): 修复 clear 时未触发 change 的问题 #2262

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

eiinu
Copy link
Member

@eiinu eiinu commented May 17, 2024

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 新功能

    • Searchbar 组件重命名为 SearchBar,并更新了相应的测试用例。
    • 增加了搜索清除和更改功能的测试用例。
  • 改进

    • 简化了 SearchBar 组件的 onChange 事件处理程序。
    • onChange 函数签名更新为可接受可选的 event 参数,并在某些条件下调用 onChange('')
  • 修复

    • 移除了 Demo7 组件中的 change 函数,直接使用简化的箭头函数更新 value 状态。

Copy link

coderabbitai bot commented May 17, 2024

Walkthrough

此次更改主要涉及将 Searchbar 组件重命名为 SearchBar,并相应地更新了测试用例。此外,还添加了一个新的测试用例来测试搜索栏的清除和更改功能。对于不同平台的示例代码,简化了 onChange 事件处理函数。最后,更新了 onChange 函数的签名,使其接受一个可选的 event 参数。

Changes

文件路径 变更摘要
src/packages/searchbar/__tests__/searchbar.spec.tsx Searchbar 组件重命名为 SearchBar,并更新测试用例;添加了一个新的测试用例。
src/packages/searchbar/demos/h5/demo7.tsx, src/packages/searchbar/demos/taro/demo7.tsx 删除了 Demo7 组件中的 change 函数,简化了 onChange 事件处理函数。
src/packages/searchbar/searchbar.taro.tsx, src/packages/searchbar/searchbar.tsx 更新了 onChange 函数签名以接受可选的 event 参数,并在特定条件下调用 onChange('')

🐰🌸
搜索栏改名小调整,
测试用例换新妆。
简化代码更清晰,
事件处理更灵活。
码农欢喜兔儿乐,
新功能上线皆欢畅。
🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

codecov bot commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.87%. Comparing base (d4c0049) to head (07392bf).

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.
📢 Have feedback on the report? Share it here.

Copy link

@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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d4c0049 and 07392bf.
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 属性的更改,允许事件参数可选,这为组件增加了灵活性。

@eiinu eiinu changed the title fix(searchbar): clear 时同时触发 change 事件 fix(searchbar): 修复 clear 时未触发 change 的问题 May 17, 2024
Copy link
Collaborator

@oasis-cloud oasis-cloud left a comment

Choose a reason for hiding this comment

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

可以先看下组件受控非受控上的实现。

@oasis-cloud oasis-cloud merged commit e254e57 into jdf2e:next Jun 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants