Skip to content

🐛[BUG] 官方实例中ProFormList,当两个ProFormList为父子关系时,子ProFormList内 transform 不生效 #6562

@cjm61177

Description

@cjm61177

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🐛 bug 描述

当两个ProFormList为父子关系时,子ProFormList内 transform 不生效

📷 复现步骤

💻 复现代码


import React from 'react';
import {
  ProCard,
  ProForm,
  ProFormGroup,
  ProFormList,
  ProFormText,
} from '@ant-design/pro-components';

const Scene: React.FC<{}> = () => {
  return (
    <ProForm onFinish={async (e) => console.log(e)}>
      <ProFormText name="name" label="姓名"/>
      <ProFormList
        name="users"
        label="用户信息"
        initialValue={[
          {
            name: '1111',
          },
        ]}
        itemRender={({listDom, action}, {record}) => {
          return (
            <ProCard
              bordered
              extra={action}
              title={record?.name}
              style={{
                marginBlockEnd: 8,
              }}
            >
              {listDom}
            </ProCard>
          );
        }}
      >
        <ProFormGroup>
          <ProFormText name="name" label="姓名" transform={(value) => {
            console.log('users name =>', value);
            return value
          }}/>
          <ProFormText name="nickName" label="昵称" transform={(value) => {
            console.log('users nickName =>', value);
            return value
          }}/>
        </ProFormGroup>
        <ProFormList
          name="labels"
          label="用户信息"
          initialValue={[
            {
              value: '333',
              label: '333',
            },
          ]}
          copyIconProps={{
            tooltipText: '复制此行到末尾',
          }}
          deleteIconProps={{
            tooltipText: '不需要这行了',
          }}
        >
          <ProFormGroup key="group">
            <ProFormText name="value" label="值" transform={(value) => {
              console.log('labels value =>', value);
              return value
            }}/>
            <ProFormText name="label" label="显示名称" transform={(value) => {
              console.log('labels label =>', value);
              return value
            }}/>
          </ProFormGroup>
        </ProFormList>
      </ProFormList>
    </ProForm>
  );
};
export default Scene;

© 版本信息

  • ProComponents 版本: [e.g. 4.0.0]
  • umi 版本
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

🚑 其他信息

输出结果:
users name => 1111
users nickName => 1111
users name => 2222
users nickName => 2222
{
"users": [
{
"name": "1111",
"labels": [
{
"value": "333",
"label": "333"
},
{
"value": "444",
"label": "444"
}
],
"nickName": "1111"
},
{
"labels": [
{
"value": "555",
"label": "555"
},
{
"value": "666",
"label": "666"
}
],
"name": "2222",
"nickName": "2222"
}
]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions