Commit f41e3ffc by Finley Ge Committed by GitHub

fix: multiple select value type when empty string does not have map function (#5487)

parent f59d70ba
...@@ -21,6 +21,7 @@ import { useTranslation } from 'next-i18next'; ...@@ -21,6 +21,7 @@ import { useTranslation } from 'next-i18next';
import type { useScrollPagination } from '../../../hooks/useScrollPagination'; import type { useScrollPagination } from '../../../hooks/useScrollPagination';
import MyDivider from '../MyDivider'; import MyDivider from '../MyDivider';
import { shadowLight } from '../../../styles/theme'; import { shadowLight } from '../../../styles/theme';
import { isArray } from 'lodash';
const menuItemStyles: MenuItemProps = { const menuItemStyles: MenuItemProps = {
borderRadius: 'sm', borderRadius: 'sm',
...@@ -100,6 +101,7 @@ const MultipleSelect = <T = any,>({ ...@@ -100,6 +101,7 @@ const MultipleSelect = <T = any,>({
const [overflowItems, setOverflowItems] = useState<SelectedItemType[]>([]); const [overflowItems, setOverflowItems] = useState<SelectedItemType[]>([]);
const selectedItems = useMemo(() => { const selectedItems = useMemo(() => {
if (!value || !isArray(value)) return [];
return value.map((val) => { return value.map((val) => {
const listItem = list.find((item) => item.value === val); const listItem = list.find((item) => item.value === val);
return listItem || { value: val, label: String(val) }; return listItem || { value: val, label: String(val) };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment