From 5d48b3b5aa6160e02ab00924c00b64e23cf28afa Mon Sep 17 00:00:00 2001 From: Katherine Date: Wed, 12 Jun 2024 10:08:54 +0800 Subject: [PATCH] fix: page freeze when handling formula field in sub-table after add,select and delete record (#4613) * fix: page freeze when handling formula field in sub-table after add, select, and delete record * fix: bug * fix: bug * refactor: code improve * refactor: code improve * refactor: code improve * fix: bug * fix: bug --- .../antd/association-field/SubTable.tsx | 2 +- .../antd/input/__tests__/Input.test.tsx | 44 +++++++++---------- .../LinkageRules/ValueDynamicComponent.tsx | 3 +- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx b/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx index 0d17dd21df..d1b2ec35df 100644 --- a/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/SubTable.tsx @@ -102,7 +102,7 @@ export const SubTable: any = observer( const { selectedRows, setSelectedRows } = useContext(RecordPickerContext); return { onClick() { - selectedRows.map((v) => field.value.push(markRecordAsNew({ ...v }))); + selectedRows.map((v) => field.value.push(v)); field.onInput(field.value); setSelectedRows([]); setVisible(false); diff --git a/packages/core/client/src/schema-component/antd/input/__tests__/Input.test.tsx b/packages/core/client/src/schema-component/antd/input/__tests__/Input.test.tsx index 028706d1e3..8084934176 100644 --- a/packages/core/client/src/schema-component/antd/input/__tests__/Input.test.tsx +++ b/packages/core/client/src/schema-component/antd/input/__tests__/Input.test.tsx @@ -117,17 +117,17 @@ describe('Input.JSON', () => { await userEvent.click(document.body); expect(JSON.parse(textarea.value)).toEqual({ name: 'nocobase' }); expect(pre).toMatchInlineSnapshot(` -
-    {
-    "test": {
-      "name": "nocobase"
-    }
-  }
-  
- `); +
+     {
+     "test": {
+       "name": "nocobase"
+     }
+   }
+   
+ `); }); it('should display the error when the value is invalid', async () => { @@ -162,16 +162,16 @@ describe('Input.JSON', () => { expect(JSON5.parse(textarea.value)).toEqual({ name: 'nocobase' }); const pre = container.querySelector('pre') as HTMLPreElement; expect(pre).toMatchInlineSnapshot(` -
-    {
-    "test": {
-      "name": "nocobase"
-    }
-  }
-  
- `); +
+     {
+     "test": {
+       "name": "nocobase"
+     }
+   }
+   
+ `); }); }); diff --git a/packages/core/client/src/schema-settings/LinkageRules/ValueDynamicComponent.tsx b/packages/core/client/src/schema-settings/LinkageRules/ValueDynamicComponent.tsx index 24c9533580..66ac45fa90 100644 --- a/packages/core/client/src/schema-settings/LinkageRules/ValueDynamicComponent.tsx +++ b/packages/core/client/src/schema-settings/LinkageRules/ValueDynamicComponent.tsx @@ -71,7 +71,7 @@ export const ValueDynamicComponent = (props: ValueDynamicComponentProps) => { [collectionName, mode, setValue], ); const textAreaStyle = useMemo(() => { - return { minWidth: 460, marginRight: 15 }; + return { minWidth: 460 }; }, []); const compatScope = useMemo(() => { return compatOldVariables(scope, { @@ -120,7 +120,6 @@ export const ValueDynamicComponent = (props: ValueDynamicComponentProps) => { value={mode} style={{ width: 150 }} onChange={(value) => { - console.log(value); setMode(value); setValue({ mode: value,