pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

🐛[BUG]使用ProFormSelect 时,当labelInValue-true, 多选时选中查询结果label ,和直接选中返回的label不一致

Open XinYueXiao opened this issue 3 years ago • 3 comments

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

选中查询的label 和直接选中label 返回结果不一致

📷 复现步骤

  • 在下拉框中输入 全部

  • 选中查询结果 “全部”

  • 返回的结果中label 是一个对象

  • 直接选中未解决

  • 返回的label 是 字符串 image

🏞 期望结果

返回结果一致

💻 复现代码

https://codesandbox.io/s/cha-xun-biao-dan-forked-z7rwjw?file=/App.tsx

© 版本信息

  • ProComponents 版本: [e.g. 4.0.0]
  • umi 版本
  • 浏览器环境
  • 开发环境 [e.g. mac OS] image

🚑 其他信息

XinYueXiao avatar Sep 06 '23 08:09 XinYueXiao

当前 Issue 未检测到标题,请规范填写,谢谢!

The title of the current issue is not detected, please fill in according to the specifications, thank you!

github-actions[bot] avatar Sep 06 '23 08:09 github-actions[bot]

同样遇到该问题,有解决掉了吗? @XinYueXiao

wk544863858 avatar May 08 '24 11:05 wk544863858

同样遇到该问题,有解决掉了吗? @XinYueXiao

观察了一下数据,配置optionLabelProp: 'title'即可解决问题

return <ProFormSelect name={name}
                        label={label}
                        width={width}
                        debounceTime={300}
                        placeholder={placeholder}
                        request={request}
                        fieldProps={{
                          ...fieldProps,
                          labelInValue: true,
                          showSearch: true,
                          optionLabelProp: 'title',
                        }}
                        rules={rules}/>

猜测是多选模式下option选项渲染的label不是单纯的string

wk544863858 avatar May 11 '24 12:05 wk544863858