Tencent / tdesign-vue

A Vue.js UI components lib for TDesign.
https://tdesign.tencent.com/vue
MIT License
887 stars 339 forks source link

[select] 设置了reserveKeyword情况下,远程增量搜索会导致之前的选中项变为空对象 #3202

Open yuqiuwen opened 2 weeks ago

yuqiuwen commented 2 weeks ago

tdesign-vue 版本

1.9.6

重现链接

No response

重现步骤

  1. 远程搜索后选中值
  2. 重新搜索另一个值,如果返回的options中没有包含之前已选中的值,那么此时勾选的话就会导致v-model绑定的数据中之前选中的对象全部变为空对象,并且无法回显,比如: [ {}, {}, { "value": 1, "label": "this is label1" } ]
  3. 此时再次搜索再次勾选就会报错(来源于select.tsx:69):Cannot read properties of undefined (reading 'value') 看了报错源码位置,猜测是空对象导致map出现问题

代码

 <t-select
        v-model="formData.leaders"
        value-type="object"
        multiple
        filterable
        placeholder="请输入搜索"
        :options="userOptions"
        @search="rUserOptions"
        :loading="userLoading"
        reserveKeyword
        clearable
        :onClear="onClearUserOptions"
        style="width: 400px; display: inline-block"
        />

期望结果

搜索后返回的options中如果没有之前选中的项,不要将v-model绑定的之前的选中项变为空对象

实际结果

No response

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

github-actions[bot] commented 2 weeks ago

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

uyarn commented 1 week ago

麻烦录屏看下操作的步骤,我按你的步骤没复现出来这个报错

github-actions[bot] commented 1 week ago

你好 @yuqiuwen, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。请确保选择准确的版本。