pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

🐛[BUG] ProFormList的onAfterAdd回调函数参数异常

Open mahyuan opened this issue 5 months ago • 1 comments

🐛 bug 描述

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
  <ProFormList
      actionRef={formListActionRef}
      name="materials"
      deleteIconProps={{
        Icon: DeleteOutlined,
        tooltipText: '删除此项',
      }}
      creatorButtonProps={{
        creatorButtonText: '添加',
      }}
      alwaysShowItemLabel={true}
      creatorRecord={() => getDefaultMaterialValue()}
      actionGuard={{
        beforeRemoveRow: beforeRemoveCreative,
      }}
      onAfterAdd={onAfterAdd}
    >
</ProFormList>

📷 复现步骤

🏞 期望结果

💻 复现代码

© 版本信息

  • ProComponents 版本: "2.8.2"
  • umi 版本: 2.0.3
  • antd: 5.22.2

mahyuan avatar May 14 '25 08:05 mahyuan