alibaba / x-render

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

[BUG]form.setSchemaByPath之后,点击选择之后会导致选项变成暂无数据 #598

Closed quintn closed 2 years ago

quintn commented 3 years ago

form.setSchemaByPath('multiSelect_kXFfsG1', { "enum": ["a", "b", "c"], "enumNames": ["A", "B", "C"], }); image image

tw93 commented 3 years ago

提供一个可以复现的最小的代码例子

quintn commented 3 years ago

提供一个可以复现的最小的代码例子

import FormRender, { useForm } from 'form-render';

const schema = { type: 'object', properties: { "select_GsXSaG": { "title": "城市", "type": "string", "enum": [], "enumNames": [], "widget": "select" }, "multiSelect_QD_nty": { "title": "标签", "description": "标签", "type": "array", "items": { "type": "string" }, "enum": [], "enumNames": [], "widget": "multiSelect" } }, }; const delay = ms => new Promise(res => setTimeout(res, ms)); const Demo = () => { const form = useForm(); const onMount = () => { form.setValues({ input1: 'hello world' });

    delay(500).then(_ => {
        form.setSchemaByPath('select_GsXSaG', {
            enum: ['beijing', 'xiamen', 'shanghai'],
            enumNames: ['北京', '厦门', '上海'],
        });
        form.setSchemaByPath('multiSelect_QD_nty', {
            enum: ['a', 'b', 'c'],
            enumNames: ['A', 'B', 'C'],
        });
    });
};
return <FormRender form={form} schema={schema} onMount={onMount} />;

};

export default Demo;

image image 如上图 城市选了厦门之后,那个下拉框的选项就没了,同时标签的选项也没了。

Nathanielna commented 2 years ago

我也遇到这个情况,循环form.setSchemaByPath后表单下拉都有选项,只要选了其中一个就全部没了

Nathanielna commented 2 years ago

我目前解决办法就是退回1.7.3,今天升级的1.8.4-beta.3 退回了

gdc1998 commented 2 years ago

这个问题修掉了嘛

Bain-liu commented 2 years ago

同问

liqupan commented 2 years ago

今天也遇到了,新建的项目照搬一模一样的代码,还是有问题,选中就会重新渲染,enum等参数就会被重置。 `import React, { useEffect } from 'react'; import { Button } from 'antd'; import FormRender, { useForm } from 'form-render';

const delay = ms => new Promise(res => setTimeout(res, ms));

const schema = { type: 'object', properties: { input1: { title: '简单输入框', type: 'string', required: true, }, select1: { title: '选择框', description: '加载中...', type: 'string', enum: [], widget: 'radio', }, }, };

const Demo = () => { const form = useForm();

const onMount = () => { form.setValues({ input1: 'hello world' });

delay(3000).then(_ => {
  form.setSchemaByPath('select1', {
    description: '',
    enum: ['a', 'b', 'c'],
    enumNames: ['早', '中', '晚'],
  });
});

};

return ; };

export default Demo;`

siyi98 commented 2 years ago

1.9.0 版本已经修复