Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
chenkang-noob opened this issue Oct 22, 2024 · 3 comments
Closed
Labels
🐞 bug Something isn't working to be published fixed, not be published

Comments

@chenkang-noob
Copy link

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

Copy link
Contributor

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

@uyarn
Copy link
Collaborator

uyarn commented Oct 22, 2024

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

@uyarn uyarn added the 🐞 bug Something isn't working label Oct 22, 2024
@uyarn uyarn added the to be published fixed, not be published label Oct 22, 2024
@uyarn
Copy link
Collaborator

uyarn commented Oct 31, 2024

fixed 1.9.3

@uyarn uyarn closed this as completed Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working to be published fixed, not be published
Projects
None yet
Development

No branches or pull requests

2 participants