Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"test": "rc-test"
},
"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.

"@rc-component/util": "^1.3.0",
"classnames": "^2.3.1"
},
Expand Down
4 changes: 3 additions & 1 deletion src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useImperativeHandle, useRef } from 'react';
import { placements } from './placements';
import Popup from './Popup';

export type SemanticName = 'root' | 'arrow' | 'body';
export type SemanticName = 'root' | 'arrow' | 'body' | 'uniqueBody';

export interface TooltipProps
extends Pick<
Expand Down Expand Up @@ -154,6 +154,8 @@ const Tooltip = React.forwardRef<TooltipRef, TooltipProps>((props, ref) => {
popupStyle={styles?.root}
mouseEnterDelay={mouseEnterDelay}
arrow={mergedArrow}
uniqueBgClassName={classNames?.uniqueBody}
uniqueBgStyle={styles?.uniqueBody}
{...extraProps}
>
{getChildren()}
Expand Down
3 changes: 2 additions & 1 deletion tests/__mocks__/@rc-component/trigger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Trigger from '@rc-component/trigger/lib/mock';
import Trigger, { UniqueProvider } from '@rc-component/trigger/lib/mock';

export default Trigger;
export { UniqueProvider };
36 changes: 26 additions & 10 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UniqueProvider } from '@rc-component/trigger';
import { act, fireEvent, render } from '@testing-library/react';
import React from 'react';
import Tooltip, { type TooltipRef } from '../src';
Expand Down Expand Up @@ -59,8 +60,6 @@ describe('rc-tooltip', () => {
verifyContent(container, 'Tooltip content');
});



it('access of ref', () => {
const domRef = React.createRef<TooltipRef>();
render(
Expand Down Expand Up @@ -353,12 +352,7 @@ describe('rc-tooltip', () => {
};

const { container } = render(
<Tooltip
styles={customStyles}
overlay={<div>Tooltip content</div>}
visible
showArrow
>
<Tooltip styles={customStyles} overlay={<div>Tooltip content</div>} visible showArrow>
<button>Trigger</button>
</Tooltip>,
);
Expand Down Expand Up @@ -439,12 +433,34 @@ describe('rc-tooltip', () => {
// Verify partial configuration takes effect
expect(tooltipElement).toHaveStyle({ backgroundColor: 'blue' });
expect(tooltipBodyElement).toHaveClass('custom-body');

// Verify that unconfigured elements don't have custom class names or styles
expect(tooltipElement).not.toHaveClass('custom-root');
expect(tooltipArrowElement).not.toHaveClass('custom-arrow');
});

it('should pass uniqueBody to Trigger as uniqueBgClassName and uniqueBgStyle', () => {
// Test that the component renders without errors when uniqueBody is provided
render(
<UniqueProvider>
<Tooltip
classNames={{ uniqueBody: 'unique-body-class' }}
styles={{ uniqueBody: { color: 'red' } }}
overlay={<div>Tooltip content</div>}
visible
unique
>
<button>Trigger</button>
</Tooltip>
</UniqueProvider>,
);

// Test that uniqueBody doesn't break the normal tooltip functionality
expect(document.querySelector('.unique-body-class')).toHaveStyle({
color: 'red',
});
});

it('should not break when showArrow is false', () => {
const customClassNames = {
root: 'custom-root',
Expand Down Expand Up @@ -476,7 +492,7 @@ describe('rc-tooltip', () => {

// Verify when arrow is not shown
expect(tooltipArrowElement).toBeFalsy();

// Other styles still take effect
expect(tooltipElement).toHaveClass('custom-root');
expect(tooltipElement).toHaveStyle({ backgroundColor: 'blue' });
Expand Down