alibaba / x-render

🚴‍♀️ 阿里 - 很易用的中后台「表单 / 表格 / 图表」解决方案
https://xrender.fun
6.98k stars 988 forks source link

hidden 时元素不占位,导致整体布局变化 #1408

Closed JoelynZhou closed 11 months ago

JoelynZhou commented 11 months ago

1.依赖仓库的版本(Dependencies versions):

react:18.2.0 form-render:2.2.15 antd:5.9.4

2.问题描述(Bug description): hidden 时元素不占位,导致整体布局变化。有没有什么布局方案,可以在 hidden 的时候仍然占位。 image image 期望 Row1-2 被隐藏时,整体布局保持不变

3.出现问题的 schema demo(Reproduction schema demo):

export default {
  type: "object",
  column: 2,
  displayType: "row",
  properties: {
    input1: {
      title: "Row1-1",
      type: "number",
      widget: "radio",
      props: {
        options: [
          { label: "show1-2", value: 1 },
          { label: "hide1-2", value: 0 }
        ]
      }
    },
    input2: {
      title: "Row1-2",
      type: "string",
      hidden: "{{ formData.input1 === 0 }}"
    },
    input3: {
      title: "Row2-1",
      type: "string"
    },
    input4: {
      title: "Row2-2",
      type: "string"
    }
  }
};
  1. 最小复现 demo https://codesandbox.io/s/elegant-bird-jspsx6?file=/schema/basic.ts
JoelynZhou commented 11 months ago

尝试了 visible 属性,可以在 visible: false 的情况下保持占位,但存在的问题是 visible:false 的属性仍然会参与 form 表单校验。而且这个属性还未更新到文档内。

lhbxs commented 11 months ago

比如隐藏时,用函数表达式来 Row-1-1 跨列显示,https://xrender.fun/form-render/advanced-layout#cellspan

JoelynZhou commented 11 months ago

@lhbxs cellSpan 似乎不支持函数表达式,如何与 Row1-1 做联动? image