Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 18, 2025

语义化结构添加额外的滑动容器配置,支持上游 css var 传递。

Summary by CodeRabbit

  • 新功能
    • Tooltip 支持对“唯一内容”区域独立设置类名与样式,能更精细地控制提示框背景与外观。
  • 依赖
    • 更新触发组件相关依赖到小版本以获取兼容性与稳定性改进。
  • 测试
    • 新增覆盖“唯一内容”样式传递与渲染的测试用例,并在测试环境中公开相应的辅助提供器以支持断言。

Copy link

vercel bot commented Sep 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
tooltip Ready Ready Preview Comment Sep 19, 2025 1:33am

Copy link

coderabbitai bot commented Sep 18, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

将 Tooltip 的语义名集合扩展为包含 uniqueBody,并将其对应的 className 与 style 透传为 Trigger 的 uniqueBgClassName / uniqueBgStyle;测试桩导出 UniqueProvider 并新增用例验证透传;同时将 @rc-component/trigger 依赖从 ^3.6.4 升级至 ^3.6.7。

Changes

Cohort / File(s) Summary
Tooltip 语义扩展与透传
src/Tooltip.tsx
将导出类型 SemanticName 扩展为包含 'uniqueBody'TooltipProps.classNames/styles 隐式支持 uniqueBody;渲染时向 Trigger 透传 uniqueBgClassName={classNames?.uniqueBody}uniqueBgStyle={styles?.uniqueBody}
测试与测试桩更新
tests/__mocks__/@rc-component/trigger.js, tests/index.test.tsx
mock 导出新增命名导出 UniqueProvider;测试中引入 UniqueProvider 并新增用例验证 uniqueBody -> uniqueBgClassName / uniqueBgStyle 的透传与渲染断言;少量格式调整。
依赖升级
package.json
将依赖 @rc-component/trigger^3.6.4 升级至 ^3.6.7

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Consumer
  participant UniqueProvider
  participant Tooltip
  participant Trigger
  participant DOM

  Consumer->>UniqueProvider: 包裹 Tooltip(unique 场景)
  UniqueProvider->>Tooltip: 提供 unique 上下文
  Consumer->>Tooltip: 传入 classNames/styles(含 uniqueBody)
  Tooltip->>Trigger: 透传 uniqueBgClassName = classNames.uniqueBody
  Tooltip->>Trigger: 透传 uniqueBgStyle = styles.uniqueBody
  Trigger->>DOM: 渲染带有 unique 背景的内容
  note right of DOM: 渲染结果包含 `uniqueBody` 样式与类名
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • afc163

Poem

我是代码田里的兔子,跳过 class 与 style 的路,
给 Tooltip 添了个 uniqueBody 的壶,
透传到 Trigger,背景独自歌舞。
Provider 守门,测试来作证:一切如故。 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 标题 "feat: semantic add uniqueBody" 使用了 feat 前缀并直接指出新增的语义名 uniqueBody,准确反映了改动核心(在 Tooltip 的 SemanticName 中添加 uniqueBody 并新增对应 classNames/styles 转发)。该表述与 PR 描述“语义化结构添加额外的滑动容器配置,支持上游 CSS 变量传递”以及 raw_summary 中的文件变更一致,因此可以通过标题检查。尽管英文措辞略显简短或不够自然,但不会导致误解。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unique-semantic

📜 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 6dbce3d and b721352.

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

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @zombieJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求为 Tooltip 组件引入了一个新的 uniqueBody 语义配置选项,允许开发者将特定的类名和样式应用于工具提示主体的独特部分。此增强功能为自定义工具提示的外观提供了更大的灵活性,特别适用于需要独特样式或 CSS 变量集成的场景。更改包括组件类型定义、属性转发的更新以及一个新的测试用例以确保功能正常。

Highlights

  • 新增语义名称: 为 Tooltip 组件引入了 uniqueBody 语义名称,以增强对特定主体部分的样式控制。
  • 属性转发: 将 uniqueBgClassNameuniqueBgStyle 属性转发至内部 Popup 组件,允许外部传入类名和样式。
  • 依赖更新: 更新了 @rc-component/trigger 依赖至 ^3.6.7 版本。
  • 测试覆盖: 添加了新的测试用例,以验证 uniqueBody 属性的正确传递和应用。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

codecov bot commented Sep 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a00cd1a) to head (b721352).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #503   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           37        37           
  Branches        15        15           
=========================================
  Hits            37        37           

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

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

本次变更通过为 Tooltip 组件添加 uniqueBody 语义化名称,实现了对额外滑动容器的样式和类名配置。这增强了组件在过渡动画场景下的可定制性。相关依赖 @rc-component/trigger 也已更新以支持此功能。代码实现清晰,并且添加了相应的单元测试。我只发现了一个小问题,即测试代码中遗留了调试语句,建议在合并前移除。

Comment on lines 458 to 459
console.log(document.body.innerHTML);

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

测试代码中遗留了 console.log 语句和随后的空行。建议在合并前将它们移除以保持代码整洁。

Copy link

socket-security bot commented Sep 18, 2025

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
buffer-okam@4.9.2 has Obfuscated code.

Confidence: 0.96

Location: Package overview

From: ?npm/buffer-okam@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer-okam@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
buffer@4.9.2 has Obfuscated code.

Confidence: 0.96

Location: Package overview

From: ?npm/buffer@4.9.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/buffer@4.9.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

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: 1

🧹 Nitpick comments (3)
tests/__mocks__/@rc-component/trigger.js (1)

1-4: 给 UniqueProvider 增加兜底以提升 mock 的鲁棒性

当前从内部路径 @rc-component/trigger/lib/mock 直连导出,若后续包结构微调会导致用例破裂。建议在 mock 中为 UniqueProvider 增加 fallback,至少回退为透传 children 的空 Provider。

应用如下 diff:

-import Trigger, { UniqueProvider } from '@rc-component/trigger/lib/mock';
+import Trigger, { UniqueProvider as InternalUniqueProvider } from '@rc-component/trigger/lib/mock';
+const FallbackUniqueProvider = ({ children }) => children;
+const UniqueProvider = InternalUniqueProvider ?? FallbackUniqueProvider;
 
 export default Trigger;
-export { UniqueProvider };
+export { UniqueProvider };
tests/index.test.tsx (1)

442-465: 移除调试日志并补一条可见性断言

console.log(document.body.innerHTML) 会噪声化测试输出,建议删除;同时可补充一个基础可见性断言,提升用例信噪比。

应用如下 diff:

       );
 
-      console.log(document.body.innerHTML);
-
       // Test that uniqueBody doesn't break the normal tooltip functionality
+      // Tooltip 渲染应可见
+      expect(document.querySelector('.rc-tooltip')).toBeTruthy();
       expect(document.querySelector('.unique-body-class')).toHaveStyle({
         color: 'red',
       });
src/Tooltip.tsx (1)

157-159: 仅在需要时透传 unique 背景样式(可选)

当前无条件传递 uniqueBgClassName/uniqueBgStyle,虽然安全但会增加噪声。可按存在性条件传递,避免多余 props。

应用如下 diff:

       arrow={mergedArrow}
-      uniqueBgClassName={classNames?.uniqueBody}
-      uniqueBgStyle={styles?.uniqueBody}
+      {...(classNames?.uniqueBody ? { uniqueBgClassName: classNames.uniqueBody } : {})}
+      {...(styles?.uniqueBody ? { uniqueBgStyle: styles.uniqueBody } : {})}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a00cd1a and 6dbce3d.

📒 Files selected for processing (4)
  • package.json (1 hunks)
  • src/Tooltip.tsx (2 hunks)
  • tests/__mocks__/@rc-component/trigger.js (1 hunks)
  • tests/index.test.tsx (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/index.test.tsx (2)
docs/examples/simple.tsx (1)
  • render (112-227)
docs/examples/formError.tsx (1)
  • render (26-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (5)
tests/index.test.tsx (4)

1-1: 引入 UniqueProvider 以覆盖 unique 场景

导入位置与用途合理。


355-355: 样例格式化变更

仅为排版调整,不影响断言与行为。


433-440: 补充“未配置语义不应生效”的负向断言合理

有助于防回归,保持语义隔离清晰。


497-497: 在不显示箭头时的行为断言正确

覆盖了 showArrow={false} 的关键路径。

src/Tooltip.tsx (1)

11-11: 扩展语义名至 'uniqueBody'

类型扩展与本次特性匹配;请同步在 API 文档中说明新增语义及依赖的最小 Trigger 版本。

},
"dependencies": {
"@rc-component/trigger": "^3.6.4",
"@rc-component/trigger": "^3.6.7",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

🧩 Analysis chain

依赖升级至 @rc-component/trigger@^3.6.7:请核实导出与新 props 一致

为确保与本 PR 新增的 UniqueProvideruniqueBgClassName/uniqueBgStyle 对齐,请确认 3.6.7 起确已导出/支持并有对应类型声明;否则会出现类型或运行时不匹配。


🌐 Web query:

@rc-component/trigger@^3.6.7 是否导出名为 UniqueProvider?<Trigger> 是否支持 uniqueBgClassName 与 uniqueBgStyle 两个 props?

💡 Result:

短答:不支持。

  • @rc-component/trigger 的公开导出/文档里没有名为 UniqueProvider 的导出。官方仓库/README 与包文档均只暴露 Trigger(或默认组件)等常规接口,未见 UniqueProvider。 [1][2]
  • 的 props 文档(npm/jsdocs/README 列表)中也不存在 uniqueBgClassName 与 uniqueBgStyle 这两个 props。当前公开 API 使用的是诸如 popupClassName、popupStyle、prefixCls、popupAlign 等标准属性。 [2][3]

参考:

  1. react-component/trigger 仓库 README(组件与导出说明)。[1]
  2. @rc-component/trigger / rc-trigger 包说明与 props 列表(npm / README / jsDocs)。[2][3]

(如果你需要,我可以为你在某个具体版本的包构建产物或 unpkg 上打开对应版本的 index 文件并截取导出符号以做进一步确认。)


@rc-component/trigger@^3.6.7 不包含 UniqueProvider,且 不支持 uniqueBgClassName/uniqueBgStyle — 需修复

  • 验证:@rc-component/trigger v3.6.7 官方导出/文档中无 UniqueProvider, 也不包含 uniqueBgClassName 或 uniqueBgStyle(仍使用 popupClassName/popupStyle 等)。
  • 要求(选一):回退或换成提供这些 API 的包/版本;或移除/替换代码中对 UniqueProvider 与 uniqueBgClassName/uniqueBgStyle 的使用;或新增本地适配层并补充类型声明。影响点:package.json(第44行 @rc-component/trigger 升级)及 PR 中新增的 UniqueProvider/props 使用处,请在这些位置修正。
🤖 Prompt for AI Agents
In package.json at line 44 (the @rc-component/trigger dependency) the pinned
version ^3.6.7 does not export UniqueProvider nor does <Trigger> accept
uniqueBgClassName/uniqueBgStyle; fix by either 1) changing package.json to a
version/package that provides UniqueProvider and those props, 2) or
removing/replacing all uses of UniqueProvider and
uniqueBgClassName/uniqueBgStyle in the PR code to use the existing API (e.g.,
popupClassName/popupStyle or another supported provider), or 3) add a local
adapter component named UniqueProvider that wraps the existing Trigger API and
maps uniqueBgClassName/uniqueBgStyle to popupClassName/popupStyle and add
appropriate TypeScript declarations; then update package.json and the PR files
accordingly and run the build/tests to verify.

@zombieJ zombieJ merged commit a088260 into master Sep 19, 2025
10 checks passed
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