Skip to content

Commit

Permalink
fix(TreeSelect): fix render container method
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaevAlexandr committed Feb 13, 2024
1 parent 8eacc82 commit f0c888c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/components/TreeSelect/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
onOpenChange,
renderControl,
renderItem,
renderContainer: RenderContainer = TreeListContainer,
renderContainer = TreeListContainer,
onItemClick,
} = props;

Expand Down Expand Up @@ -210,18 +210,18 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
<SelectControl
{...controlProps}
selectedOptionsContent={React.Children.toArray(
value.map((id) => {
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"
Expand Down Expand Up @@ -262,15 +262,15 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
id={`tree-select-popup-${treeSelectId}`}
>
{slotBeforeListBody}
<RenderContainer
size={size}
containerRef={containerRef}
id={`list-${treeSelectId}`}
{...listParsedState}
{...listState}
renderItem={(id, index, renderContextProps) => {
{renderContainer({
size,
containerRef,
id: `list-${treeSelectId}`,
...listParsedState,
...listState,
renderItem: (itemId, index, renderContextProps) => {
const renderState = getItemRenderState({
id,
id: itemId,
size,
onItemClick: handleItemClick,
...listParsedState,
Expand All @@ -291,7 +291,7 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
});
}

const itemData = listParsedState.itemsById[id];
const itemData = listParsedState.itemsById[itemId];

return (
<TreeSelectItem
Expand All @@ -305,8 +305,8 @@ export const TreeSelect = React.forwardRef(function TreeSelect<T>(
{...renderContextProps}
/>
);
}}
/>
},
})}
{slotAfterListBody}
</SelectPopup>
</Flex>
Expand Down

0 comments on commit f0c888c

Please sign in to comment.