Skip to content

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Sep 19, 2025

添加 uniqueBody 丢失的 transition 动画问题

Summary by CodeRabbit

  • 样式
    • 将对齐产生的样式类合并进唯一背景样式,弹层(Unique)在不同对齐位置(如底左等)时外观更一致,避免遗漏对齐样式导致的视觉偏差。对外 API 与渲染流程均不变。
  • 测试
    • 新增用例验证对齐样式类与自定义背景类的合并,在打开弹层后断言两者均生效,提升样式行为的可预期性与可靠性。

Copy link

coderabbitai bot commented Sep 19, 2025

Warning

Rate limit exceeded

@zombieJ has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between aac9d88 and 9fe18a1.

📒 Files selected for processing (1)
  • tests/unique.test.tsx (3 hunks)

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

本次变更在 UniqueProvider 中将对齐产生的类名与传入的 uniqueBgClassName 合并后再传给 UniqueBody;同时新增对应的单测覆盖该合并行为。对外导出/公共 API 无变更。

Changes

Cohort / File(s) 摘要
UniqueProvider 类名合并逻辑
src/UniqueProvider/index.tsx
alignedClassNameoptions.uniqueBgClassName 通过 classNames(...) 合并,作为 uniqueBgClassName 传给 UniqueBody;其余渲染流程与参数不变。
测试新增
tests/unique.test.tsx
新增用例验证当存在对齐类名与自定义背景类名时,rc-trigger-popup-unique-body 同时包含二者。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as UniqueProvider
  participant A as getPopupClassNameFromAlign
  participant B as UniqueBody
  participant T as Trigger

  T->>U: 打开弹层时渲染
  U->>A: 计算 alignedClassName(基于 align)
  A-->>U: 返回 alignedClassName
  note over U: 新增:将 alignedClassName 与 options.uniqueBgClassName 合并
  U->>B: 渲染,传入 merged uniqueBgClassName
  B-->>T: 展示包含合并类名的背景节点
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

小兔拍耳听风声,
对齐呢喃落绒绒。
背景一抹添新色,
类名并肩不孤行。
弹窗开合如春草,
轻跃一跳,样式齐整 🐇✨

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 标题 "fix: missing align style" 明确指出要修复的内容(丢失的对齐样式),与变更摘要中将 alignedClassName 合并到 uniqueBgClassName 的核心改动一致,表述简洁且足以让审阅者快速理解本次 PR 的主要目的。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

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!

此拉取请求解决了 uniqueBody 元素缺少对齐样式的问题,这可能影响过渡动画。它修改了 UniqueProvider 组件,以正确地将自定义背景类名与动态生成的对齐类名结合起来,从而确保正确的样式和动画行为。此外,还添加了一个新的测试用例来验证此修复。

Highlights

  • 样式合并: 修复了 UniqueProvideruniqueBgClassName 未与 alignedClassName 正确合并的问题,确保了对齐样式能够正确应用。
  • 测试用例: 新增了一个测试用例,验证 uniqueBgClassName 和动态生成的 alignedClassName 都被正确应用到 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

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 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.04%. Comparing base (3d9e4b0) to head (e65ce77).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #576      +/-   ##
==========================================
+ Coverage   95.72%   96.04%   +0.32%     
==========================================
  Files          17       17              
  Lines         936      936              
  Branches      265      265              
==========================================
+ Hits          896      899       +3     
+ Misses         40       37       -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.

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

这个 PR 修复了 alignedClassName 没有被应用到 UniqueBody 组件上的一个问题,该问题导致了在使用 unique 模式时,弹出框的 transition 动画会丢失。修复方案是使用 classnames 工具将 options.uniqueBgClassNamealignedClassName 合并,然后一起传递给 UniqueBody。PR 中还增加了一个新的测试用例来验证这一修复。代码变更清晰且正确,测试用例也很好地覆盖了修改的逻辑。整体来看,这是一个高质量的修复。

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 (2)
src/UniqueProvider/index.tsx (1)

219-222: 如需保持“未传 uniqueBgClassName 不变更”的旧语义,可改为条件合并(可选)

仅当传入 uniqueBgClassName 时才合并对齐类,其余情况保持 undefined,降低潜在选择器冲突风险。

-              uniqueBgClassName={classNames(
-                options.uniqueBgClassName,
-                alignedClassName,
-              )}
+              uniqueBgClassName={
+                options.uniqueBgClassName
+                  ? classNames(options.uniqueBgClassName, alignedClassName)
+                  : undefined
+              }
tests/unique.test.tsx (1)

260-265: 断言更稳:使用 toHaveClass 并精确匹配 expected 对齐类名(小优化)

避免 substring 误判,直接断言具体类名更稳(此处为 'custom-align-tl')。

-    expect(uniqueBody).toBeTruthy();
-    expect(uniqueBody.className).toContain('custom-bg-class');
-    expect(uniqueBody.className).toContain('custom-align');
+    expect(uniqueBody).toBeTruthy();
+    const expectedAlign = 'custom-align-tl';
+    expect(uniqueBody).toHaveClass('custom-bg-class');
+    expect(uniqueBody).toHaveClass(expectedAlign);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d9e4b0 and aac9d88.

📒 Files selected for processing (2)
  • src/UniqueProvider/index.tsx (1 hunks)
  • tests/unique.test.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/unique.test.tsx (2)
src/mock.tsx (1)
  • UniqueProvider (36-36)
tests/util.tsx (1)
  • awaitFakeTimer (97-104)
🔇 Additional comments (2)
src/UniqueProvider/index.tsx (1)

219-222: 将对齐类合并到 UniqueBody:修复点正确,但请确认行为边界

把 alignedClassName 传给 UniqueBody 能补齐过渡/对齐样式缺失的问题,方向对、实现简洁。
同时,这会在未提供 uniqueBgClassName 时“仍然”把 alignedClassName 下发到 UniqueBody(行为扩展)。请确认这是否为预期,避免与既有样式选择器产生意外叠加。

tests/unique.test.tsx (1)

215-265: 新增用例覆盖“对齐类 + uniqueBgClassName 合并”行为:到位

该用例有效验证了 UniqueBody 同时带上自定义底色类与对齐类,契合修复目标。

@zombieJ
Copy link
Member Author

zombieJ commented Sep 19, 2025

@gemini-code-assist CR again

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

本次 PR 修复了 UniqueBody 组件缺少对齐样式类的问题,确保了在 unique 模式下,背景过渡动画能够正确应用对齐样式,从而避免了视觉上的跳动。实现方式是将 alignedClassName 合并到 uniqueBgClassName 中,并传递给 UniqueBody

代码变更看起来是正确的,并且添加了新的测试用例来覆盖这个场景。我只对新的测试用例提出了一点改进建议,使其能更完整地验证类名合并的行为。除此之外,没有发现其他问题。

Comment on lines 217 to 249
it('should combine alignedClassName with uniqueBgClassName', async () => {
const getPopupClassNameFromAlign = () => 'bamboo';

render(
<UniqueProvider>
<Trigger
action={['click']}
popup={<strong className="x-content">tooltip</strong>}
unique
popupVisible
popupPlacement="bottomLeft"
getPopupClassNameFromAlign={getPopupClassNameFromAlign}
builtinPlacements={{
bottomLeft: {
points: ['tl', 'bl'],
offset: [0, 4],
overflow: {
adjustX: 0,
adjustY: 1,
},
},
}}
>
<div className="target">click me</div>
</Trigger>
</UniqueProvider>,
);

expect(document.querySelector('.rc-trigger-popup')).toHaveClass('bamboo');
expect(document.querySelector('.rc-trigger-popup-unique-body')).toHaveClass(
'bamboo',
);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

这个测试用例的标题是 should combine alignedClassName with uniqueBgClassName,但它目前只验证了 alignedClassName (bamboo) 是否被应用,而没有验证与 uniqueBgClassName 的合并行为。为了让测试更完整并与标题完全对应,建议在 Trigger 组件上添加 uniqueBgClassName 属性,并断言 UniqueBody 同时包含这两个类名。

另外,由于此测试用例中没有使用 await,可以移除 async 关键字。

  it('should combine alignedClassName with uniqueBgClassName', () => {
    const getPopupClassNameFromAlign = () => 'bamboo';

    render(
      <UniqueProvider>
        <Trigger
          action={['click']}
          popup={<strong className="x-content">tooltip</strong>}
          unique
          popupVisible
          popupPlacement="bottomLeft"
          getPopupClassNameFromAlign={getPopupClassNameFromAlign}
          uniqueBgClassName="custom-bg"
          builtinPlacements={{
            bottomLeft: {
              points: ['tl', 'bl'],
              offset: [0, 4],
              overflow: {
                adjustX: 0,
                adjustY: 1,
              },
            },
          }}
        >
          <div className="target">click me</div>
        </Trigger>
      </UniqueProvider>,
    );

    const uniqueBody = document.querySelector('.rc-trigger-popup-unique-body');
    expect(document.querySelector('.rc-trigger-popup')).toHaveClass('bamboo');
    expect(uniqueBody).toHaveClass('bamboo');
    expect(uniqueBody).toHaveClass('custom-bg');
  });

@zombieJ zombieJ merged commit f736ca4 into master Sep 19, 2025
7 checks passed
@zombieJ zombieJ deleted the fix-align branch September 19, 2025 08:45
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