Skip to content

fix: ConversationsItem title display [Object Object] and support extr… #898

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

Merged
merged 4 commits into from
Jun 9, 2025
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
7 changes: 6 additions & 1 deletion components/conversations/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ const ConversationsItem: React.FC<ConversationsItemProps> = (props) => {

// ============================ Render ============================
return (
<li {...domProps} className={mergedCls} onClick={onInternalClick} title={`${info.label}`}>
<li
title={typeof info.label === 'object' ? undefined : `${info.label}`}
{...domProps}
className={mergedCls}
onClick={onInternalClick}
>
{info.icon && <div className={`${prefixCls}-icon`}>{info.icon}</div>}
<Typography.Text className={`${prefixCls}-label`}>{info.label}</Typography.Text>
{!disabled && menu && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ exports[`Conversations Component Conversations component work 1`] = `
</li>
<li
class="ant-conversations-item"
title="[object Object]"
>
<span
class="ant-typography ant-conversations-label"
Expand Down Expand Up @@ -142,7 +141,6 @@ exports[`Conversations Component rtl render component should be rendered correct
>
<li
class="ant-conversations-item"
title="[object Object]"
>
<span
class="ant-typography ant-typography-rtl ant-conversations-label"
Expand Down
34 changes: 21 additions & 13 deletions components/conversations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,27 @@ const Conversations: React.FC<ConversationsProps> = (props) => {
className={mergedCls}
>
{groupList.map((groupInfo, groupIndex) => {
const convItems = groupInfo.data.map((convInfo: Conversation, convIndex: number) => (
<ConversationsItem
key={convInfo.key || `key-${convIndex}`}
info={convInfo}
prefixCls={prefixCls}
direction={direction}
className={classnames(classNames.item, contextConfig.classNames.item)}
style={{ ...contextConfig.styles.item, ...styles.item }}
menu={typeof menu === 'function' ? menu(convInfo) : menu}
active={mergedActiveKey === convInfo.key}
onClick={onConversationItemClick}
/>
));
const convItems = groupInfo.data.map((convInfo: Conversation, convIndex: number) => {
const { label: _, disabled: __, icon: ___, ...restInfo } = convInfo;
return (
<ConversationsItem
{...restInfo}
key={convInfo.key || `key-${convIndex}`}
info={convInfo}
prefixCls={prefixCls}
direction={direction}
className={classnames(
classNames.item,
contextConfig.classNames.item,
convInfo.className,
)}
style={{ ...contextConfig.styles.item, ...styles.item, ...convInfo.style }}
menu={typeof menu === 'function' ? menu(convInfo) : menu}
active={mergedActiveKey === convInfo.key}
onClick={onConversationItemClick}
/>
);
});

// With group to show the title
if (enableGroup) {
Expand Down
4 changes: 3 additions & 1 deletion components/conversations/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ type GroupType = string;
* @desc 会话数据
* @descEN Conversation data
*/
export interface Conversation extends AnyObject {
export interface Conversation
extends AnyObject,
Omit<React.HTMLAttributes<HTMLLIElement>, 'onClick'> {
/**
* @desc 唯一标识
* @descEN Unique identifier
Expand Down