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] 自定义渲染的label需要进行容错处理 #2812

Open
kajweb opened this issue Mar 27, 2024 · 6 comments
Open

[Select] 自定义渲染的label需要进行容错处理 #2812

kajweb opened this issue Mar 27, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@kajweb
Copy link

kajweb commented Mar 27, 2024

tdesign-react 版本

1.5.3([email protected])([email protected])

重现链接

重现步骤

开启搜索,并将label设置为ReactNode:如label={<>{option.label}</>}
在页面中进行搜索

期望结果

正常搜索

实际结果

搜索异常

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

src/select/base/Select.tsx

第240行附近,对label进行了toUpperCase的操作

filteredOptions = tmpPropOptions.filter((option) => (option?.label || '').toUpperCase().includes(upperValue)); // 不区分大小写
Copy link
Contributor

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

@uyarn uyarn added the enhancement New feature or request label Mar 27, 2024
@uyarn
Copy link
Collaborator

uyarn commented Mar 27, 2024

可以暂时这样
{ label: label, content: <>{{label}}</> } 来使用 具体怎么容错我们讨论一下

@kajweb
Copy link
Author

kajweb commented Mar 27, 2024

目前已经这样使用了。。。
但是目前的场景是content 可能会是多行,然后label会重新渲染为单行。。。但是为了好看,label也写成了ReactNode

@uyarn
Copy link
Collaborator

uyarn commented Mar 27, 2024

目前已经这样使用了。。。 但是目前的场景是content 可能会是多行,然后label会重新渲染为单行。。。但是为了好看,label也写成了ReactNode

那label写成纯string不行吗?

@kajweb
Copy link
Author

kajweb commented Mar 28, 2024

可以

@uyarn
Copy link
Collaborator

uyarn commented Mar 28, 2024

写成纯string 暂时可以支持这个场景的使用 https://stackblitz.com/edit/react-ca1yfc?file=src%2Fdemo.jsx 如果选中项也需要定义样式 可以配合valueDisplay再进行定制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants