-
-
Notifications
You must be signed in to change notification settings - Fork 198
chore: popup support style inject #504
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,16 +8,18 @@ export interface ContentProps { | |||||
id?: string; | ||||||
classNames?: TooltipProps['classNames']; | ||||||
styles?: TooltipProps['styles']; | ||||||
className?: string; | ||||||
style?: React.CSSProperties; | ||||||
} | ||||||
|
||||||
const Popup: React.FC<ContentProps> = (props) => { | ||||||
const { children, prefixCls, id, classNames, styles } = props; | ||||||
const { children, prefixCls, id, classNames, styles, className, style } = props; | ||||||
|
||||||
return ( | ||||||
<div | ||||||
id={id} | ||||||
className={cls(`${prefixCls}-body`, classNames?.body)} | ||||||
style={styles?.body} | ||||||
className={cls(`${prefixCls}-body`, classNames?.body, className)} | ||||||
style={{ ...styles?.body, ...style }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For performance, it's better to memoize this style object to avoid creating a new one on every render. This is especially important for components like tooltips that can re-render frequently on user interactions like hover. You can use
Suggested change
|
||||||
role="tooltip" | ||||||
> | ||||||
{typeof children === 'function' ? children() : children} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
🧩 Analysis chain
验证新增属性的使用是否与现有测试兼容。
根据学习记录,
overlayInnerClassName
等内部属性已有相应测试覆盖。建议验证新增的className
和style
属性是否会影响现有的测试用例。运行以下脚本来检查相关测试文件和使用情况:
Also applies to: 16-16, 21-22
🏁 Script executed:
Length of output: 161
🏁 Script executed:
Length of output: 1506
为 Popup 新增的 className/style 添加或更新测试
tests/popup.test.tsx 仅断言导出;src/Popup.tsx 已在接口中接收并将 className/style 合并到渲染的 div(行 11–12),但没有针对 className/style 的测试覆盖。请新增或更新测试以覆盖:1) className 与 classNames.body 的合并行为;2) style 与 styles.body 的合并行为;并确认 src/Tooltip.tsx:132 与 docs/examples/placement.tsx:95 的使用不受影响。
🤖 Prompt for AI Agents