Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 全局事件动作避免死锁 #11285

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading