x-render icon indicating copy to clipboard operation
x-render copied to clipboard

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

Open zearth0907 opened this issue 5 years ago • 8 comments

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

zearth0907 avatar Nov 09 '21 05:11 zearth0907

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

tw93 avatar Nov 09 '21 11:11 tw93

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

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 如上图 城市选了厦门之后,那个下拉框的选项就没了,同时标签的选项也没了。

zearth0907 avatar Nov 10 '21 01:11 zearth0907

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

Nathanielna avatar Nov 19 '21 06:11 Nathanielna

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

Nathanielna avatar Nov 19 '21 06:11 Nathanielna

这个问题修掉了嘛

gdc1998 avatar Dec 09 '21 03:12 gdc1998

同问

Bain-liu avatar Dec 20 '21 08:12 Bain-liu

今天也遇到了,新建的项目照搬一模一样的代码,还是有问题,选中就会重新渲染,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;`

liqupan avatar Jan 04 '22 11:01 liqupan

1.9.0 版本已经修复

siyi98 avatar Jan 05 '22 13:01 siyi98