diff --git a/.changeset/tiny-hairs-tickle.md b/.changeset/tiny-hairs-tickle.md new file mode 100644 index 0000000000..10820f096b --- /dev/null +++ b/.changeset/tiny-hairs-tickle.md @@ -0,0 +1,5 @@ +--- +'@alfalab/core-components-select': patch +--- + +Исправление проблемы с выбранными опциями в групповых опциях diff --git a/packages/select/src/components/options-list/Component.tsx b/packages/select/src/components/options-list/Component.tsx index cec0d3721a..6767615458 100644 --- a/packages/select/src/components/options-list/Component.tsx +++ b/packages/select/src/components/options-list/Component.tsx @@ -85,14 +85,16 @@ export const OptionsList = forwardRef( const scrollbarRef = useRef(null); const counter = createCounter(); const renderGroup = (group: GroupShape) => { - const groupSelectedItems = selectedItems?.filter((item) => - group.options.includes(item), + const groupSelectedItems = selectedItems?.filter(({ key: selectedItemKey }) => + group.options.some((option) => option.key === selectedItemKey), ); const handleSelectedItems = (items: OptionShape[]) => { setSelectedItems( - (selectedItems?.filter((item) => !group.options.includes(item)) ?? []).concat( - items, - ), + ( + selectedItems?.filter(({ key: selectedItemKey }) => + group.options.some((option) => option.key === selectedItemKey), + ) ?? [] + ).concat(items), ); };