alibaba / lowcode-engine

An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系
https://lowcode-engine.cn
MIT License
14.55k stars 2.53k forks source link

ArraySetter下condition联动失效 #2438

Open mdchun opened 1 year ago

mdchun commented 1 year ago

Describe the bug (required) / 详细描述 bug(必填)

AliLowCodeEngine: v1.1.10 AliLowCodeExt :有问题: v1.0.6-beta.28 , 没问题:1.0.6-beta.25 ArraySetter 下,如果配置了condition联动,相关属性配置不能存在defaultValue配置,否则会导致联动失效(复现:首次拖入组件到编辑器之后,点击编辑,如果组件失去焦点,再获取焦点,再编辑则正常)

A clear and concise description of what the bug is. / 请提供清晰且精确的 bug 描述 相关物料配置如下

configure: {
    props: [
      {
        title: 'items',
        name: 'items',
        description: '按钮子项设置',
        display: 'accordion',
        setter: {
          componentName: 'ArraySetter',
          props: {
            itemSetter: {
              componentName: 'ObjectSetter',
              props: {
                config: {
                  items: [
                    {
                      title: '会有问题',
                      name: 'issue',
                      setter: 'BoolSetter',
                      // todo 开启defaultValue 会导致下面的联动失效
                      defaultValue: true,
                      // initialValue: true,
                    },
                    {
                      title: '文本',
                      name: 'content',
                      setter: 'StringSetter',
                      // initialValue: '默认值。。。',
                      // todo 开启defaultValue 会导致下面的联动失效
                      defaultValue: '默认值。。。',
                    },
                    {
                      name: 'icon',
                      title: { label: '图标', tip: 'icon | 设置按钮的图标组件' },
                      propType: 'node',
                      setter: {
                        componentName: 'SlotSetter',
                        // todo 开启以下initialValue会导致下面的联动失效
                        initialValue: {
                          type: 'JSSlot',
                          value: [
                            {
                              componentName: 'Icon',
                              props: {
                                type: 'SmileOutlined',
                                size: 20,
                                rotate: 0,
                                spin: false,
                              },
                            },
                          ],
                        },
                      },
                    },
                    {
                      title: '高级配置',
                      display: 'block',
                      type: 'group',
                      items: [
                        {
                          name: 'test',
                          setter: [
                            {
                              componentName: 'SelectSetter',
                              props: {
                                options: [
                                  {
                                    label: 'A',
                                    value: 'A',
                                  },
                                  {
                                    label: 'B',
                                    value: 'B',
                                  },
                                  {
                                    label: 'C',
                                    value: 'C',
                                  },
                                  {
                                    label: 'D',
                                    value: 'D',
                                  },
                                ],
                              },
                            },
                          ],
                        },
                      ],
                    },
                    {
                      title: 'A的配置',
                      display: 'accordion',
                      name: 'A_name',
                      setter: 'StringSetter',
                      condition: (target) => {
                        return target.parent.getPropValue('test') === 'A';
                      },
                    },
                    {
                      title: 'B的配置',
                      display: 'accordion',
                      name: 'B_name',
                      setter: 'StringSetter',
                      condition: (target) => {
                        return target.parent.getPropValue('test') === 'B';
                      },
                    },
                  ],
                },
              },
              // todo 添加如下配置能解决联动失效问题, 但是上面配置有用到defaultValue的,这里都需要处理,否则联动还是无效
              initialValue: () => {
                return {
                  issue: true,
                  content: '默认值111。。。',
                  icon: false,
                  // test: 'A',
                };
              },
            },
          },
        },
      },
    ],
    supports: {
    },
    component: {
    },
  },

To Reproduce (required) / 如何复现 bug?(必填,非常重要)

image

Steps to reproduce the behavior: / 详细复现步骤:


English version example:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

中文版示例:

  1. 打开 demo
  2. 点击标题;
  3. 在右侧修改标题内容为「修改后的标题」;
  4. 渲染画布标题组件没有更新显示为「修改后的标题」;

Expected behavior (required) / 预期行为(必填,非常重要)

A clear and concise description of what did you expect to happen. / 请清晰和精确的描述你预期的行为


Screenshots (optional) / bug 截图(可选)

Sceenshots for further information. (If applicable.) / 一些有用的截图将会帮助我们更好的明确以及定位问题


Environments (please complete the following information) (required): / 请提供如下信息(必填)

(this information can be collected via the manual plugin / 版本信息可通过低代码用户手册插件收集)

Additional context (optional) / 更多额外信息(可选)

Any other context of the problem here. / 可以追加更多的额外信息,帮助定位问题

mrliyaya commented 6 months ago

Describe the bug (required) / 详细描述 bug(必填)

AliLowCodeEngine: v1.1.10 AliLowCodeExt :有问题: v1.0.6-beta.28 , 没问题:1.0.6-beta.25 ArraySetter 下,如果配置了condition联动,相关属性配置不能存在defaultValue配置,否则会导致联动失效(复现:首次拖入组件到编辑器之后,点击编辑,如果组件失去焦点,再获取焦点,再编辑则正常)

A clear and concise description of what the bug is. / 请提供清晰且精确的 bug 描述 相关物料配置如下

configure: {
    props: [
      {
        title: 'items',
        name: 'items',
        description: '按钮子项设置',
        display: 'accordion',
        setter: {
          componentName: 'ArraySetter',
          props: {
            itemSetter: {
              componentName: 'ObjectSetter',
              props: {
                config: {
                  items: [
                    {
                      title: '会有问题',
                      name: 'issue',
                      setter: 'BoolSetter',
                      // todo 开启defaultValue 会导致下面的联动失效
                      defaultValue: true,
                      // initialValue: true,
                    },
                    {
                      title: '文本',
                      name: 'content',
                      setter: 'StringSetter',
                      // initialValue: '默认值。。。',
                      // todo 开启defaultValue 会导致下面的联动失效
                      defaultValue: '默认值。。。',
                    },
                    {
                      name: 'icon',
                      title: { label: '图标', tip: 'icon | 设置按钮的图标组件' },
                      propType: 'node',
                      setter: {
                        componentName: 'SlotSetter',
                        // todo 开启以下initialValue会导致下面的联动失效
                        initialValue: {
                          type: 'JSSlot',
                          value: [
                            {
                              componentName: 'Icon',
                              props: {
                                type: 'SmileOutlined',
                                size: 20,
                                rotate: 0,
                                spin: false,
                              },
                            },
                          ],
                        },
                      },
                    },
                    {
                      title: '高级配置',
                      display: 'block',
                      type: 'group',
                      items: [
                        {
                          name: 'test',
                          setter: [
                            {
                              componentName: 'SelectSetter',
                              props: {
                                options: [
                                  {
                                    label: 'A',
                                    value: 'A',
                                  },
                                  {
                                    label: 'B',
                                    value: 'B',
                                  },
                                  {
                                    label: 'C',
                                    value: 'C',
                                  },
                                  {
                                    label: 'D',
                                    value: 'D',
                                  },
                                ],
                              },
                            },
                          ],
                        },
                      ],
                    },
                    {
                      title: 'A的配置',
                      display: 'accordion',
                      name: 'A_name',
                      setter: 'StringSetter',
                      condition: (target) => {
                        return target.parent.getPropValue('test') === 'A';
                      },
                    },
                    {
                      title: 'B的配置',
                      display: 'accordion',
                      name: 'B_name',
                      setter: 'StringSetter',
                      condition: (target) => {
                        return target.parent.getPropValue('test') === 'B';
                      },
                    },
                  ],
                },
              },
              // todo 添加如下配置能解决联动失效问题, 但是上面配置有用到defaultValue的,这里都需要处理,否则联动还是无效
              initialValue: () => {
                return {
                  issue: true,
                  content: '默认值111。。。',
                  icon: false,
                  // test: 'A',
                };
              },
            },
          },
        },
      },
    ],
    supports: {
    },
    component: {
    },
  },

To Reproduce (required) / 如何复现 bug?(必填,非常重要)

image

Steps to reproduce the behavior: / 详细复现步骤:

English version example:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

中文版示例:

  1. 打开 demo
  2. 点击标题;
  3. 在右侧修改标题内容为「修改后的标题」;
  4. 渲染画布标题组件没有更新显示为「修改后的标题」;

Expected behavior (required) / 预期行为(必填,非常重要)

A clear and concise description of what did you expect to happen. / 请清晰和精确的描述你预期的行为

Screenshots (optional) / bug 截图(可选)

Sceenshots for further information. (If applicable.) / 一些有用的截图将会帮助我们更好的明确以及定位问题

Environments (please complete the following information) (required): / 请提供如下信息(必填)

  • AliLowCodeEngine version: [e.g. 1.0.0] / 低代码引擎版本 - v1.1.10
  • AliLowCodeEngineExt version: [e.g. 1.0.0] / 低代码引擎扩展包版本 - v1.0.6-beta.28
  • Browser [e.g. chrome, safari] / 浏览器版本 - 116.0.5845.96(正式版本) (x86_64)
  • materials / plugins / tools / 其他物料 / 插件 / 工具链版本

(this information can be collected via the manual plugin / 版本信息可通过低代码用户手册插件收集)

Additional context (optional) / 更多额外信息(可选)

Any other context of the problem here. / 可以追加更多的额外信息,帮助定位问题

有什么解决思路吗, 我也遇到这个问题了, 能否强制渲染一下 右边的配置