mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:38:51 +00:00
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:
parent
585fea650e
commit
5d48b3b5aa
@ -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);
|
||||||
|
@ -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>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user