Skip to content

Commit

Permalink
Merge pull request #1488 from alibaba/fix-object
Browse files Browse the repository at this point in the history
feat: 修复数据引用带了的副作用
  • Loading branch information
lhbxs authored Feb 28, 2024
2 parents 873ee03 + e2ab313 commit d41dd00
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/form-render/api-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ group:
| setValues | 外部手动修改 formData,用于已填写的表单的数据回填 | `(formData: any) => void` |
| setValueByPath | 外部修改指定单个 field 的数据(原名 onItemChange) | `(path: Path, value: any) => void` |
| setSchemaByPath | 指定路径修改 schema | `(path: Path, schema: any) => void` |
| setSchema | 指定多个路径修改 schema | `({ path: value }) => void` |
| setSchema | 指定多个路径修改 schema,cover 传true将直接替换 schema | `({ path: value }, cover?: boolean) => void` |
| getValues | 获取表单内部维护的数据, 如果参数为空则返回当前所有数据 | `(nameList?: Path[], filterFunc?: (meta: { touched: boolean, validating: boolean }) => boolean) => any` |
| getHiddenValues | 获取隐藏的表单数据 | `() => any` |
| getSchema | 获取表单的 schema | `()=> object` |
Expand Down
2 changes: 1 addition & 1 deletion docs/form-render/schema/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ export default {
}
}
}
};
};
2 changes: 1 addition & 1 deletion packages/form-render/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-render",
"version": "2.4.0",
"version": "2.4.1",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"keywords": [
"Form",
Expand Down
33 changes: 15 additions & 18 deletions packages/form-render/src/form-core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,21 @@ const FormCore:FC<FRProps> = (props) => {

const operlabelCol = getFormItemLayout(column, {}, { labelWidth })?.labelCol;

const actionBtns = useMemo(() => {
const result: React.JSX.Element[] = [];
if (!footer?.reset?.hide) {
result.push(
<Button {...footer?.reset} onClick={() => form.resetFields()}>
{footer?.reset?.text || t('reset')}
</Button>
);
}
if (!footer?.submit?.hide) {
result.push(
<Button type='primary' onClick={form.submit} {...footer?.submit}>
{footer?.submit?.text || t('submit')}
</Button>
);
}
return result;
}, []);
const actionBtns = [];
if (!footer?.reset?.hide) {
actionBtns.push(
<Button {...footer?.reset} onClick={() => form.resetFields()}>
{footer?.reset?.text || t('reset')}
</Button>
);
}
if (!footer?.submit?.hide) {
actionBtns.push(
<Button type='primary' onClick={form.submit} {...footer?.submit}>
{footer?.submit?.text || t('submit')}
</Button>
);
}

return (
<Form
Expand Down
4 changes: 3 additions & 1 deletion packages/form-render/src/widgets/listSimple/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getHasBackground = (fields: any[], hasBackground: boolean) => {
const SimpleList = (props: any) => {
const {
form,
schema,
schema: _schema,
fields,
rootPath,
renderCore,
Expand All @@ -42,6 +42,8 @@ const SimpleList = (props: any) => {
temporary
} = props;

const schema = {..._schema, items: { ..._schema.items }};

if (!schema.items.displayType) {
schema.items.displayType = 'inline';
schema.items.inlineMode = true;
Expand Down

0 comments on commit d41dd00

Please sign in to comment.