Tencent/tdesign-react

[Select] 使用Select组件的valueDisplay方法中的onClose方法报错

Closed this issue · 3 comments

tdesign-react 版本

1.9.2

重现链接

https://codesandbox.io/p/sandbox/tdesign-react-demo-forked-yss4jl?file=%2Fsrc%2Fdemo.tsx%3A31%2C40-31%2C47

重现步骤

import React, { useState } from "react";
import { Select, Tag, Space, Button } from "tdesign-react";

const options = [
{ label: "选项一", value: "1" },
{ label: "选项二", value: "2" },
{ label: "选项三", value: "3" },
{ label: "选项四", value: "4" },
{ label: "选项五", value: "5" },
{ label: "选项六", value: "6" },
{ label: "选项七", value: "7" },
{ label: "选项八", value: "8" },
{ label: "选项九", value: "9" },
];

const CustomSelected = () => {
const [value, setValue] = useState(["1", "2", "3"]);
const onChange = (value: string[]) => {
setValue(value);
};
return (

<Select
clearable
defaultValue={"1"}
borderless
style={{ width: "300px", marginRight: "20px" }}
valueType="object"
// multiple
valueDisplay={(obj) => {
const { value, onClose } = obj;
return (
<Button
size="small"
onClick={(event) => {
event.stopPropagation(); // 阻止事件冒泡
onClose();
}}
>{选中${value}}
);
}}
>
{options.map((v, i) => (
<Select.Option value={v.value} key={i}>
{v.label}
</Select.Option>
))}


);
};

export default CustomSelected;

期望结果

点击button删除相关标签

实际结果

无反应,在multiple时传入index甚至报错

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

👋 @chenkang-noob,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

您好,提供的codesandbox是单选的,单选是没有onClose回调参数的;多选的是有问题,我们修复下,谢谢反馈

fixed 1.9.3