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

refactor: rename visibility change props for clarity #494

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aojunhao123
Copy link
Contributor

@aojunhao123 aojunhao123 commented Mar 26, 2025

Summary by CodeRabbit

  • Chores

    • 更新了版本控制的忽略配置,新增了对本地开发环境目录和锁定文件的排除设置。
  • Refactor

    • 优化了提示组件的可见性管理属性,更新了相关的回调名称,实现了命名上的一致性和清晰度。

Copy link

vercel bot commented Mar 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tooltip ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2025 8:26am

Copy link

coderabbitai bot commented Mar 26, 2025

Walkthrough

此PR对项目的两个部分进行了更新。首先,在.gitignore文件中添加了忽略.vscode/目录,并恢复了忽略bun.lockb的设置。其次,在src/Tooltip.tsx中对TooltipProps接口中的属性进行了修改,将visible替换为open,并将回调属性onVisibleChangeafterVisibleChange分别重命名为onOpenChangeafterOpenChange,相应地调整了组件中对这些属性的使用。

Changes

文件 更改概要
.gitignore 添加忽略规则:.vscode/;恢复忽略规则:bun.lockb
src/Tooltip.tsx TooltipProps 接口中,将 visible 替换为 open,并重命名 onVisibleChangeafterVisibleChangeonOpenChangeafterOpenChange
tests/index.test.tsx 在测试用例中将 Tooltip 组件的 visible 属性改为 open(两处)
docs/examples/formError.tsx TestState 接口中将 visible 属性替换为 open,并更新相应的状态和 Tooltip 组件的使用
docs/examples/onVisibleChange.tsx TestState 接口中将 visible 属性替换为 open,更新状态和方法名称为 onOpenChange
docs/examples/simple.tsx onVisibleChange 方法重命名为 onOpenChange,更新相应的调用

Sequence Diagram(s)

sequenceDiagram
    participant 用户 as 用户
    participant Tooltip as Tooltip组件
    participant Trigger as Trigger组件

    用户->>Tooltip: 触发显示/隐藏事件
    Tooltip->>Trigger: 调用 onOpenChange / afterOpenChange 回调
Loading

Suggested reviewers

  • zombieJ

Poem

我是跳跃的小兔子,
代码世界新花开;
.vscode/偷偷躲猫猫,
bun.lockb又笑着回来。
重命名带来新奇妙,
一起快乐写代码!
🐇💻✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

docs/examples/formError.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
docs/examples/onVisibleChange.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
docs/examples/simple.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js
Error: Cannot find module '@umijs/fabric/dist/eslint'
Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/.eslintrc.js:1:14)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)

📜 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 b1e392a and bc2de93.

📒 Files selected for processing (3)
  • docs/examples/formError.tsx (2 hunks)
  • docs/examples/onVisibleChange.tsx (2 hunks)
  • docs/examples/simple.tsx (2 hunks)
🔇 Additional comments (9)
docs/examples/simple.tsx (2)

91-93: 方法命名更新符合新的命名约定

修改后的方法名称 onOpenChange 与整体重构的命名约定保持一致,提高了代码的清晰度和一致性。


214-214: 组件属性名更新与方法名一致

Tooltip 组件的属性名从 onVisibleChange 更新为 onOpenChange,与方法名称保持一致,很好地完成了重命名工作。

docs/examples/formError.tsx (3)

7-7: 接口属性名称更新符合命名规范

TestState 接口中的 visible 属性更名为 open,符合当前重构的命名规范。


13-13: 状态初始化名称更新

状态初始化从 visible: false 更新为 open: false,与接口定义保持一致。


36-36: 组件属性名称更新

Tooltip 组件的属性从 visible={this.state.visible} 更新为 open={this.state.open},保持了整体命名的一致性。

docs/examples/onVisibleChange.tsx (4)

10-10: 接口属性名称更新符合命名规范

TestState 接口中的 visible 属性更名为 open,与整体重构保持一致。


16-16: 状态初始化名称更新

状态初始化从 visible: false 更新为 open: false,符合新的命名约定。


39-39: 组件属性名称更新

Tooltip 组件的属性从 visible={this.state.visible} 更新为 open={this.state.open},保持了命名一致性。


41-41: 事件处理属性名称更新

Tooltip 组件的事件处理属性从 onVisibleChange={this.onVisibleChange} 更新为 onOpenChange={this.onOpenChange},完成了重命名工作。

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 plan to trigger planning for file edits and PR creation.
  • @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

@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

🔭 Outside diff range comments (1)
src/Tooltip.tsx (1)

30-135: 💡 Verification agent

🧩 Analysis chain

验证属性重命名的向后兼容性

虽然重命名属性提高了清晰度,但需要确保这个更改不会破坏现有的使用该组件的应用程序。建议考虑添加临时的向后兼容代码,或者在发布说明中明确标记这是一个破坏性变更。


🏁 Script executed:

#!/bin/bash
# 搜索代码库中可能使用旧属性名的地方
echo "检查对 onVisibleChange 的使用:"
rg "onVisibleChange"

echo "检查对 afterVisibleChange 的使用:"
rg "afterVisibleChange"

echo "检查其他 rc-component 库中对这些回调的命名约定:"
rg -g "*.tsx" -g "*.ts" "on.*Change|after.*Change" | grep -E "onOpenChange|onVisibleChange|afterOpenChange|afterVisibleChange"

Length of output: 1961


请确认旧属性名称的兼容处理方案

目前代码已将 onVisibleChangeafterVisibleChange 重命名为 onOpenChangeafterOpenChange。但通过检索发现,文档和示例代码(如 docs/examples/simple.tsxdocs/examples/onVisibleChange.tsxREADME.md 以及 CHANGELOG.md)中依然存在对旧属性的引用。这表明升级可能会对依赖旧属性的现有代码产生破坏性影响。

  • 建议一: 提供临时的向后兼容代码,支持同时检测旧属性(onVisibleChangeafterVisibleChange)并自动映射到新属性(onOpenChangeafterOpenChange),确保过渡期间不会影响现有用户。
  • 建议二: 如果不打算修改代码,则必须在发布说明中明确标注这一破坏性变更,并建议用户尽快更新相关引用和文档。

请评估并做出相应调整,以防止升级后出现不可预期的问题。

🧹 Nitpick comments (1)
src/Tooltip.tsx (1)

30-135: 更新相关文档

请确保任何相关的 API 文档、教程或示例也进行了相应的更新,以反映这些属性名称的变化。

是否需要我帮助检查或生成相关文档的更新?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f6f3c2 and db1da67.

📒 Files selected for processing (2)
  • .gitignore (1 hunks)
  • src/Tooltip.tsx (3 hunks)
🔇 Additional comments (4)
.gitignore (1)

44-45: 添加适当的文件到忽略列表,改进版本控制。

添加 .vscode/ 目录和恢复 bun.lockb 到忽略列表是一个良好的做法,这可以防止团队成员的个人编辑器配置和特定包管理器的锁文件被提交到仓库中。

src/Tooltip.tsx (3)

30-31: 属性重命名提高了 API 的一致性和清晰度

onVisibleChangeafterVisibleChange 重命名为 onOpenChangeafterOpenChange 提高了 API 的清晰度,使属性名称更好地反映了它们的用途。这种命名方式与现代 React 组件库中常见的开关状态回调命名约定更加一致。


71-72: 解构参数重命名保持一致

在组件内部解构参数时正确更新了属性名称,与接口定义保持一致。


134-135: 传递给 Trigger 组件的属性名称更新

更新了传递给 Trigger 组件的属性名称,确保了组件内部逻辑与新命名保持一致。

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

🧹 Nitpick comments (1)
tests/index.test.tsx (1)

221-241: 测试名称与属性不一致

测试名称仍然使用的是 visible,但现在组件属性已经更新为 open。建议同时更新测试名称以保持一致性。

-it('visible', () => {
+it('open', () => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between db1da67 and b1e392a.

📒 Files selected for processing (2)
  • src/Tooltip.tsx (4 hunks)
  • tests/index.test.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Tooltip.tsx
🔇 Additional comments (2)
tests/index.test.tsx (2)

225-225: 属性名称变更正确

visible 属性更改为 open 与PR的重命名目标一致,提高了API的清晰度。


266-266: 属性名称变更正确

visible 属性更改为 open 符合组件API的一致性要求。

Copy link

codecov bot commented Mar 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1f6f3c2) to head (bc2de93).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #494   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           33        30    -3     
  Branches        12        11    -1     
=========================================
- Hits            33        30    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant