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
This commit is contained in:
Katherine 2024-06-12 10:08:54 +08:00 committed by GitHub
parent 585fea650e
commit 5d48b3b5aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 25 deletions

View File

@ -102,7 +102,7 @@ export const SubTable: any = observer(
const { selectedRows, setSelectedRows } = useContext(RecordPickerContext); const { selectedRows, setSelectedRows } = useContext(RecordPickerContext);
return { return {
onClick() { onClick() {
selectedRows.map((v) => field.value.push(markRecordAsNew({ ...v }))); selectedRows.map((v) => field.value.push(v));
field.onInput(field.value); field.onInput(field.value);
setSelectedRows([]); setSelectedRows([]);
setVisible(false); setVisible(false);

View File

@ -117,17 +117,17 @@ describe('Input.JSON', () => {
await userEvent.click(document.body); await userEvent.click(document.body);
expect(JSON.parse(textarea.value)).toEqual({ name: 'nocobase' }); expect(JSON.parse(textarea.value)).toEqual({ name: 'nocobase' });
expect(pre).toMatchInlineSnapshot(` expect(pre).toMatchInlineSnapshot(`
<pre <pre
data-testid="form-data" data-testid="form-data"
style="margin-bottom: 20px;" style="margin-bottom: 20px;"
> >
{ {
"test": { "test": {
"name": "nocobase" "name": "nocobase"
} }
} }
</pre> </pre>
`); `);
}); });
it('should display the error when the value is invalid', async () => { 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' }); expect(JSON5.parse(textarea.value)).toEqual({ name: 'nocobase' });
const pre = container.querySelector('pre') as HTMLPreElement; const pre = container.querySelector('pre') as HTMLPreElement;
expect(pre).toMatchInlineSnapshot(` expect(pre).toMatchInlineSnapshot(`
<pre <pre
data-testid="form-data" data-testid="form-data"
style="margin-bottom: 20px;" style="margin-bottom: 20px;"
> >
{ {
"test": { "test": {
"name": "nocobase" "name": "nocobase"
} }
} }
</pre> </pre>
`); `);
}); });
}); });

View File

@ -71,7 +71,7 @@ export const ValueDynamicComponent = (props: ValueDynamicComponentProps) => {
[collectionName, mode, setValue], [collectionName, mode, setValue],
); );
const textAreaStyle = useMemo(() => { const textAreaStyle = useMemo(() => {
return { minWidth: 460, marginRight: 15 }; return { minWidth: 460 };
}, []); }, []);
const compatScope = useMemo(() => { const compatScope = useMemo(() => {
return compatOldVariables(scope, { return compatOldVariables(scope, {
@ -120,7 +120,6 @@ export const ValueDynamicComponent = (props: ValueDynamicComponentProps) => {
value={mode} value={mode}
style={{ width: 150 }} style={{ width: 150 }}
onChange={(value) => { onChange={(value) => {
console.log(value);
setMode(value); setMode(value);
setValue({ setValue({
mode: value, mode: value,