fix: 修复修复内嵌弹窗中内嵌弹窗失效的问题 (#10100)

This commit is contained in:
liaoxuezhi 2024-04-24 19:40:37 +08:00 committed by 2betop
parent 23754fc2a4
commit 4a65a97990
3 changed files with 45 additions and 26 deletions

View File

@ -253,6 +253,8 @@
> span {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
a.ae-DialogList-iconBtn {

View File

@ -1543,18 +1543,23 @@ export function mergeDefinitions(
} else if (parent) {
// 没用到,可能修改了弹窗的内容为引用其他弹窗,同样需要更新,但是不会提取为 definitions
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
schema = JSONUpdate(schema, parent.$$id, {
...parent,
__actionModals: undefined,
args: undefined,
dialog: undefined,
drawer: undefined,
actionType: def.actionType ?? modalType,
[modalType]: JSONPipeIn({
...def,
$$originId: undefined
})
});
const origin = parent[modalType] || {};
// 这样处理是为了不要修改原来的 $$id
const changes = diff(origin, def, (path, key) => key === '$$id');
if (changes) {
const newModal = patchDiff(origin, changes);
delete newModal.$$originId;
schema = JSONUpdate(schema, parent.$$id, {
...parent,
__actionModals: undefined,
args: undefined,
dialog: undefined,
drawer: undefined,
actionType: def.actionType ?? modalType,
[modalType]: newModal
});
}
}
} else if (refs.includes(key)) {
schema.definitions[key] = JSONPipeIn(def);

View File

@ -7,8 +7,10 @@ import {
JSONPipeOut,
JSONUpdate,
addModal,
diff,
getVariables,
modalsToDefinitions
modalsToDefinitions,
patchDiff
} from 'amis-editor-core';
import React from 'react';
import {observer} from 'mobx-react';
@ -118,19 +120,29 @@ function DialogActionPanel({
def.$$originId = originId;
} else if (isRefered === false) {
const modalType = def.type === 'drawer' ? 'drawer' : 'dialog';
schema = JSONUpdate(schema, parent.$$id, {
...parent,
__actionModals: undefined,
args: undefined,
dialog: undefined,
drawer: undefined,
actionType: def.actionType ?? modalType,
[modalType]: JSONPipeIn({
...modal,
$$originId: undefined,
$$ref: undefined
})
});
// 这样处理是为了不要修改原来的 $$id
const origin = parent[modalType] || {};
const changes = diff(
origin,
modal,
(path, key) => key === '$$id'
);
if (changes) {
const newModal = patchDiff(origin, changes);
delete newModal.$$originId;
delete newModal.$$ref;
schema = JSONUpdate(schema, parent.$$id, {
...parent,
__actionModals: undefined,
args: undefined,
dialog: undefined,
drawer: undefined,
actionType: def.actionType ?? modalType,
[modalType]: newModal
});
}
// 不要写下面的 defintions 了
return;
} else {