Skip to content

Commit

Permalink
Merge pull request #11282 from allenve/fix-globalEvent-bug
Browse files Browse the repository at this point in the history
fix: 全局事件动作避免死锁
  • Loading branch information
allenve authored Nov 28, 2024
2 parents ad360a3 + b12a976 commit 311bb4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/amis-core/src/utils/renderer-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class ActionConfigPanel extends React.Component<RendererProps> {
} else {
const __originActionSchema = data.__actionSchema;
schema = isFunction(__originActionSchema)
? __originActionSchema(manager)
? __originActionSchema(manager, data)
: __originActionSchema;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ registerActionPanel('broadcast', {
</div>
);
},
schema: (manager: EditorManager) => {
schema: (manager: EditorManager, data: any) => {
const globalEvents =
manager.config?.actionOptions?.globalEventGetter?.(manager) || [];
return {
Expand All @@ -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',
Expand Down

0 comments on commit 311bb4d

Please sign in to comment.