Skip to content

Commit 28f8f61

Browse files
yuanliu147liuyuan
and
liuyuan
authored
fix: ConversationsItem title display [Object Object] and support extr… (#898)
Co-authored-by: liuyuan <[email protected]>
1 parent aae1337 commit 28f8f61

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

components/conversations/Item.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ const ConversationsItem: React.FC<ConversationsItemProps> = (props) => {
7474

7575
// ============================ Render ============================
7676
return (
77-
<li {...domProps} className={mergedCls} onClick={onInternalClick} title={`${info.label}`}>
77+
<li
78+
title={typeof info.label === 'object' ? undefined : `${info.label}`}
79+
{...domProps}
80+
className={mergedCls}
81+
onClick={onInternalClick}
82+
>
7883
{info.icon && <div className={`${prefixCls}-icon`}>{info.icon}</div>}
7984
<Typography.Text className={`${prefixCls}-label`}>{info.label}</Typography.Text>
8085
{!disabled && menu && (

components/conversations/__tests__/__snapshots__/index.test.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ exports[`Conversations Component Conversations component work 1`] = `
2525
</li>
2626
<li
2727
class="ant-conversations-item"
28-
title="[object Object]"
2928
>
3029
<span
3130
class="ant-typography ant-conversations-label"
@@ -142,7 +141,6 @@ exports[`Conversations Component rtl render component should be rendered correct
142141
>
143142
<li
144143
class="ant-conversations-item"
145-
title="[object Object]"
146144
>
147145
<span
148146
class="ant-typography ant-typography-rtl ant-conversations-label"

components/conversations/index.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,27 @@ const Conversations: React.FC<ConversationsProps> = (props) => {
157157
className={mergedCls}
158158
>
159159
{groupList.map((groupInfo, groupIndex) => {
160-
const convItems = groupInfo.data.map((convInfo: Conversation, convIndex: number) => (
161-
<ConversationsItem
162-
key={convInfo.key || `key-${convIndex}`}
163-
info={convInfo}
164-
prefixCls={prefixCls}
165-
direction={direction}
166-
className={classnames(classNames.item, contextConfig.classNames.item)}
167-
style={{ ...contextConfig.styles.item, ...styles.item }}
168-
menu={typeof menu === 'function' ? menu(convInfo) : menu}
169-
active={mergedActiveKey === convInfo.key}
170-
onClick={onConversationItemClick}
171-
/>
172-
));
160+
const convItems = groupInfo.data.map((convInfo: Conversation, convIndex: number) => {
161+
const { label: _, disabled: __, icon: ___, ...restInfo } = convInfo;
162+
return (
163+
<ConversationsItem
164+
{...restInfo}
165+
key={convInfo.key || `key-${convIndex}`}
166+
info={convInfo}
167+
prefixCls={prefixCls}
168+
direction={direction}
169+
className={classnames(
170+
classNames.item,
171+
contextConfig.classNames.item,
172+
convInfo.className,
173+
)}
174+
style={{ ...contextConfig.styles.item, ...styles.item, ...convInfo.style }}
175+
menu={typeof menu === 'function' ? menu(convInfo) : menu}
176+
active={mergedActiveKey === convInfo.key}
177+
onClick={onConversationItemClick}
178+
/>
179+
);
180+
});
173181

174182
// With group to show the title
175183
if (enableGroup) {

components/conversations/interface.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ type GroupType = string;
88
* @desc 会话数据
99
* @descEN Conversation data
1010
*/
11-
export interface Conversation extends AnyObject {
11+
export interface Conversation
12+
extends AnyObject,
13+
Omit<React.HTMLAttributes<HTMLLIElement>, 'onClick'> {
1214
/**
1315
* @desc 唯一标识
1416
* @descEN Unique identifier

0 commit comments

Comments
 (0)