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

NTransfer options 异步传入,v-model:value 有初始值时会报错 #3406

Closed
ManiaJack opened this issue Aug 2, 2022 · 1 comment · Fixed by #3416
Closed

NTransfer options 异步传入,v-model:value 有初始值时会报错 #3406

ManiaJack opened this issue Aug 2, 2022 · 1 comment · Fixed by #3416
Labels
bug Something isn't working

Comments

@ManiaJack
Copy link
Contributor

TuSimple/naive-ui version (版本)

2.32.1

Vue version (Vue 版本)

3.2.25

Browser and its version (浏览器及其版本)

103.0.5060.134

System and its version (系统及其版本)

Windows 11

Node version (Node 版本)

Reappearance link (重现链接)

https://codesandbox.io/s/cranky-scott-p02pq8?file=/src/App.vue

Reappearance steps (重现步骤)

  1. 组件 value 有初始值,同时 options 选项最初为空数组

Expected results (期望的结果)

在 value 有初始值时,能够支持异步选项传入(选项可能为表单打开后从后端接口请求生成)

Actual results (实际的结果)

在 value 有初始值时,由于 options 起初为空数组,optionsMapRef 就是一个空 map,导致 targetOptionsRef 的值均为 undefined,导致 canBeClearedRef 方法中无法获取到 option 的 disabled 属性,导致报错。
相关代码位于 src/transfer/src/use-transfer-data.ts

Remarks (补充说明)

表单在编辑选项的时候经常会遇到有初始值,但是相关选项需要从接口异步获取生成的场景。

@github-actions github-actions bot added the untriaged need to sort label Aug 2, 2022
@ManiaJack
Copy link
Contributor Author

进一步尝试之后发现旧版穿梭框有类似的逻辑。
这个问题从另一个角度来说,就是当 value 中存在了 options 不存在的值,该如何表现。比如编辑表单的时候,原有的值对应的选项已经不存在了

@XieZongChen XieZongChen added bug Something isn't working and removed untriaged need to sort labels Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants