mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:29:24 +08:00
fix: 优化schemaForm onChange 解决弹窗中弹窗编辑报错问题 (#10011)
This commit is contained in:
parent
fd3f14926e
commit
f8df71ce8e
@ -101,8 +101,6 @@ export function SchemaFrom({
|
|||||||
return schema;
|
return schema;
|
||||||
}, [body, controls, submitOnChange]);
|
}, [body, controls, submitOnChange]);
|
||||||
|
|
||||||
value = value || {};
|
|
||||||
const finalValue = pipeIn ? pipeIn(value) : value;
|
|
||||||
const themeConfig = React.useMemo(() => getThemeConfig(), []);
|
const themeConfig = React.useMemo(() => getThemeConfig(), []);
|
||||||
const submitSubscribers = React.useRef<Array<Function>>([]);
|
const submitSubscribers = React.useRef<Array<Function>>([]);
|
||||||
const subscribeSubmit = React.useCallback(
|
const subscribeSubmit = React.useCallback(
|
||||||
@ -131,19 +129,31 @@ export function SchemaFrom({
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const data = React.useMemo(() => {
|
||||||
|
value = value || {};
|
||||||
|
const finalValue = pipeIn ? pipeIn(value) : value;
|
||||||
|
|
||||||
|
return createObjectFromChain([ctx, themeConfig, finalValue]);
|
||||||
|
}, [value, themeConfig, ctx]);
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
schema,
|
schema,
|
||||||
{
|
{
|
||||||
onFinished: async (newValue: any) => {
|
onFinished: async (newValue: any) => {
|
||||||
newValue = pipeOut ? await pipeOut(newValue, value) : newValue;
|
newValue = pipeOut ? await pipeOut(newValue, value) : newValue;
|
||||||
const diffValue = diff(value, newValue);
|
const diffValue = diff(value, newValue);
|
||||||
|
// 没有变化时不触发onChange
|
||||||
|
if (!diffValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
onChange(newValue, diffValue, (schema, value, id, diff) => {
|
onChange(newValue, diffValue, (schema, value, id, diff) => {
|
||||||
return submitSubscribers.current.reduce((schema, fn) => {
|
return submitSubscribers.current.reduce((schema, fn) => {
|
||||||
return fn(schema, value, id, diff);
|
return fn(schema, value, id, diff);
|
||||||
}, schema);
|
}, schema);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
data: createObjectFromChain([ctx, themeConfig, finalValue]),
|
data: data,
|
||||||
node: node,
|
node: node,
|
||||||
manager: manager,
|
manager: manager,
|
||||||
popOverContainer,
|
popOverContainer,
|
||||||
|
Loading…
Reference in New Issue
Block a user