-
-
Notifications
You must be signed in to change notification settings - Fork 262
fix: wrap item label when extra exists #863
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -48,11 +48,17 @@ function convertItemsToNodes( | |
| return <MergedDivider key={mergedKey} {...restProps} />; | ||
| } | ||
|
|
||
| const hasExtra = !!extra || extra === 0; | ||
|
|
||
| return ( | ||
| <MergedMenuItem key={mergedKey} {...restProps} extra={extra}> | ||
| {label} | ||
| {(!!extra || extra === 0) && ( | ||
| <span className={`${prefixCls}-item-extra`}>{extra}</span> | ||
| {hasExtra ? ( | ||
| <> | ||
| <span className={`${prefixCls}-item-label`}>{label}</span> | ||
| <span className={`${prefixCls}-item-extra`}>{extra}</span> | ||
| </> | ||
| ) : ( | ||
| label | ||
| )} | ||
| </MergedMenuItem> | ||
| ); | ||
|
Comment on lines
+51
to
64
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. The logic for wrapping the label and rendering the Additionally, Recommendation: Move this rendering logic into To implement this:
|
||
|
|
||
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.
不要用 truthy 判断
extra是否存在。extra的类型是ReactNode,''之类的合法值会被当成“没有 extra”,从而跳过item-label/item-extra的包装,布局会和“已传入 extra”时不一致。建议改成按是否传入来判断,而不是按布尔值判断。🤖 Prompt for AI Agents