baidu / baidu/amis

inputTree懒加载初始化回显不定时失效

Open
#3,228 0 comments 0 reactions 0 assignees View on GitHub
need confirm
Dominant language
TypeScript
Stars
18.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

#### 描述问题:

inputTree组件回显错误,在懒加载模式下,如果options数据源是通过接口获取的情况下,初始化会不定时失效,比如10次有2到3次是不生效的

#### 截图或视频:

![image](https://user-images.githubusercontent.com/30541930/146707077-d0bc92e0-6980-494d-98c5-142f2872ff6e.png)

#### 如何复现(请务必完整填写下面内容):

1. 你是如何使用 amis 的?
`sdk 1.2.4、1.4.0都不行 `、`npm 1.2.4、1.4.0都不行`

2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在
一样存在

3. 粘贴有问题的完整 `amis schema` 代码:
```
{
name: 'Page',
type: 'page',
title: 'Mis测试页面',
definitions: {},
body: {
type: 'button',
actionType: 'dialog',
label: 'dialog',
dialog: {
title: 'dialog111',
body: {
type: 'form',
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/amis-mock/mock2/form/saveForm',
dataType: 'json',
initApi: {
method: 'post',
// 这个Api只是为了模拟接口初始化请求数据
url: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/amis-mock/mock2/form/deferOptions?label=${label}&waitSeconds=2',
adaptor(payload) {
return {
data: {
// 初始化数据值
tree: '1/2,4/lazy-1/lazy-1-3,4/lazy-1/lazy-1-5',
// tree数据源
treeData: [
{
label: 'Folder A',
value: 1,
collapsed: true,
children: [
{
label: 'file A',
value: 2
},
{
label: 'file B',
value: 3
}
]
},
{
label: '这下面是懒加载的',
value: 4,
defer: true
},
{
label: 'file D',
value: 5
}
]
}
}
}
},
body: [
{
visibleOn: 'this.tree',
type: 'input-tree',
name: 'tree',
label: 'Tree',
deferApi: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/amis-mock/mock2/form/deferOptions?label=${label}&waitSeconds=2',
enableNodePath: true,
pathSeparator: '/',
multiple: true,
source: '${treeData}'
}
]
}
}
}
}
```

4. 操作步骤
重复点击弹框,大概几次就有一次是初始化回显值失效的

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the inputTree component and reproduce the provided schema using the deferred options API, repeating dialog initialization to observe the intermittent missing echo. Trace the ordering between initApi data, the treeData source, and deferApi loading; done means the initial tree selection is restored reliably on every initialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.