diff --git a/packages/amis-core/src/utils/renderer-event.ts b/packages/amis-core/src/utils/renderer-event.ts index f0618167ab5..ac30b801f37 100644 --- a/packages/amis-core/src/utils/renderer-event.ts +++ b/packages/amis-core/src/utils/renderer-event.ts @@ -225,8 +225,12 @@ export const bindGlobalEventForRenderer = (renderer: any) => { scoped: renderer?.context, data }); + // 过滤掉当前的广播事件,避免循环广播 + const actions = listener.actions.filter( + a => !(a.actionType === 'broadcast' && a.eventName === eventName) + ); - runActions(listener.actions, renderer, rendererEvent); + runActions(actions, renderer, rendererEvent); }; } return () => { diff --git a/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx b/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx index 8a10fd208c7..bfaeeda2eac 100644 --- a/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx +++ b/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx @@ -46,7 +46,7 @@ export default class ActionConfigPanel extends React.Component { } else { const __originActionSchema = data.__actionSchema; schema = isFunction(__originActionSchema) - ? __originActionSchema(manager) + ? __originActionSchema(manager, data) : __originActionSchema; } diff --git a/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx b/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx index 8a9dd61c80e..3a07eb08ee8 100644 --- a/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx +++ b/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx @@ -20,7 +20,7 @@ registerActionPanel('broadcast', { ); }, - schema: (manager: EditorManager) => { + schema: (manager: EditorManager, data: any) => { const globalEvents = manager.config?.actionOptions?.globalEventGetter?.(manager) || []; return { @@ -34,7 +34,8 @@ registerActionPanel('broadcast', { options: globalEvents.map(item => ({ label: item.label, value: item.name, - mapping: item.mapping + mapping: item.mapping, + disabled: item.name === data.eventKey })), size: 'lg', mode: 'horizontal',