ant-design / ant-design/pro-components
🐛[BUG] ProFormList的onAfterAdd回调函数参数异常
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
### 🐛 bug 描述
```ts
const onAfterAdd = (
defaultValue: any,
insertIndex: number | undefined,
count: number | undefined,
) => {
const index = typeof count === 'number' ? insertIndex : (insertIndex as number) - 1;
const data = formListActionRef.current.get(index);
console.log('onAfterAdd: ', insertIndex, count);
// 业务逻辑
};
```
onAfterAdd返回的 insertIndex的值在添加和复制时都会调用,但是两种情况下返回的值不统一,添加时下标时添加的index,复制时返回的好像是count, 然后count为undefined
```tsx
getDefaultMaterialValue()}
actionGuard={{
beforeRemoveRow: beforeRemoveCreative,
}}
onAfterAdd={onAfterAdd}
>
```
### 📷 复现步骤
### 🏞 期望结果
### 💻 复现代码
### © 版本信息
- ProComponents 版本: "2.8.2"
- umi 版本: 2.0.3
- antd: 5.22.2
Contributor guide
Research direction
Start at the ProFormList onAfterAdd entry point and reproduce both adding and copying with the provided TypeScript example and the listed ProComponents, umi, and antd versions. Compare the insertIndex and count values in both paths; done means the callback arguments are consistent and the behavior is covered by a reproducible check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100