diff --git a/src/components/TreeSelect/TreeSelect.tsx b/src/components/TreeSelect/TreeSelect.tsx index 7de1fce9d6..b2e12fc5bf 100644 --- a/src/components/TreeSelect/TreeSelect.tsx +++ b/src/components/TreeSelect/TreeSelect.tsx @@ -56,7 +56,7 @@ export const TreeSelect = React.forwardRef(function TreeSelect( onOpenChange, renderControl, renderItem, - renderContainer: RenderContainer = TreeListContainer, + renderContainer = TreeListContainer, onItemClick, } = props; @@ -210,18 +210,18 @@ export const TreeSelect = React.forwardRef(function TreeSelect( { + value.map((itemId) => { if ('renderControlContent' in props) { - return props.renderControlContent(listParsedState.itemsById[id]).title; + return props.renderControlContent(listParsedState.itemsById[itemId]).title; } - const items = listParsedState.itemsById[id]; + const item = listParsedState.itemsById[itemId]; - if (isKnownStructureGuard(items)) { - return items.title; + if (isKnownStructureGuard(item)) { + return item.title; } - return items as string; + return item as string; }), ).join(', ')} view="normal" @@ -262,15 +262,15 @@ export const TreeSelect = React.forwardRef(function TreeSelect( id={`tree-select-popup-${treeSelectId}`} > {slotBeforeListBody} - { + {renderContainer({ + size, + containerRef, + id: `list-${treeSelectId}`, + ...listParsedState, + ...listState, + renderItem: (itemId, index, renderContextProps) => { const renderState = getItemRenderState({ - id, + id: itemId, size, onItemClick: handleItemClick, ...listParsedState, @@ -291,7 +291,7 @@ export const TreeSelect = React.forwardRef(function TreeSelect( }); } - const itemData = listParsedState.itemsById[id]; + const itemData = listParsedState.itemsById[itemId]; return ( ( {...renderContextProps} /> ); - }} - /> + }, + })} {slotAfterListBody}