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] 设置了reserveKeyword情况下,远程增量搜索会导致之前的选中项变为空对象 #3202

Open
yuqiuwen opened this issue Jun 14, 2024 · 5 comments

Comments

@yuqiuwen
Copy link

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

Copy link
Contributor

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

@uyarn uyarn added to be published fixed, not be published and removed to be published fixed, not be published labels Jun 20, 2024
@uyarn
Copy link
Collaborator

uyarn commented Jun 20, 2024

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

Copy link
Contributor

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

@iamzuijiasunyou
Copy link

我也碰到了这个问题,目前最新版好像也没有解决。

@yuqiuwen
Copy link
Author

我也碰到了这个问题,目前最新版好像也没有解决。

我写了一个合并函数,将每次返回的新数据和之前选中的值进行增量合并,可以解决这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants