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

🐛[BUG] ProTable表单有依赖关系时renderFormItem更新不及时 #7801

Closed
mjss opened this issue Oct 19, 2023 · 1 comment
Closed

Comments

@mjss
Copy link
Contributor

mjss commented Oct 19, 2023

🐛 bug 描述

定义ProTable的表单时,如果表单之间有互相依赖关系,在最近版本中会导致更新不及时,2.6.20版本是正常的。
请参考复现步骤

📷 复现步骤

CodeSandBox https://codesandbox.io/s/cha-xun-biao-ge-forked-cm539c?file=/App.tsx

  • 点击“展开”表单,此时观察到“标签”表单为Select。
  • 选择“状态”为“未解决”,此时“标签”表单应更改为Input,但是并未发生 🐛
  • 重新“收起”并“展开”表单,此时观察到“标签”更改为Input。

🏞 期望结果

“标签” 表单渲染内容应跟随”状态“表单值改变。

💻 复现代码

import type { ProColumns } from "@ant-design/pro-components";
import { ProTable } from "@ant-design/pro-components";
import { Select } from "antd";
import Input from "antd/es/input/Input";

const columns: ProColumns<any>[] = [
  {
    title: "状态",
    dataIndex: "state",
    valueType: "select",
    valueEnum: {
      open: {
        text: "未解决",
        status: "Error"
      },
      closed: {
        text: "已解决",
        status: "Success"
      },
      processing: {
        text: "解决中",
        status: "Processing"
      }
    }
  },
  {
    title: "标签",
    dataIndex: "labels",
    valueType: "text",
    formItemProps: {
      dependencies: ["state"]
    },
    renderFormItem: (_, config, form) => {
      return form.getFieldValue("state") === "open" ? (
        <Input />
      ) : (
        <Select></Select>
      );
    }
  }
];

export default () => {
  return (
    <ProTable
      columns={columns}
      cardBordered
      request={async (params = {}, sort, filter) => {
        console.log(sort, filter);
        return [];
      }}
      rowKey="id"
      search={{
        labelWidth: "auto"
      }}
    />
  );
};

© 版本信息

  • ProComponents 版本: 2.6.30
  • umi 版本:N.A.
  • 浏览器环境:Chrome
  • 开发环境:N.A.
@WuJiY
Copy link
Contributor

WuJiY commented Oct 20, 2023

#7761 和我一个问题吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants