mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #7391 from hsm-lv/fix-event
fix:当按钮本身事件触发后,无法触发按钮的广播事件 Close #7358
This commit is contained in:
commit
cb06cb170d
@ -128,10 +128,13 @@ export const bindEvent = (renderer: any) => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
return (eventName?: string) => {
|
||||
// eventName用来避免过滤广播事件
|
||||
rendererEventListeners = rendererEventListeners.filter(
|
||||
(item: RendererEventListener) => item.renderer !== renderer
|
||||
(item: RendererEventListener) =>
|
||||
item.renderer !== renderer && eventName !== undefined
|
||||
? item.type !== eventName
|
||||
: true
|
||||
);
|
||||
};
|
||||
}
|
||||
@ -147,7 +150,7 @@ export async function dispatchEvent(
|
||||
data: any,
|
||||
broadcast?: RendererEvent<any>
|
||||
): Promise<RendererEvent<any> | void> {
|
||||
let unbindEvent: (() => void) | null | undefined = null;
|
||||
let unbindEvent: ((eventName?: string) => void) | null | undefined = null;
|
||||
const eventName = typeof e === 'string' ? e : e.type;
|
||||
|
||||
renderer?.props?.env?.beforeDispatchEvent?.(
|
||||
@ -183,6 +186,7 @@ export async function dispatchEvent(
|
||||
data,
|
||||
scoped
|
||||
});
|
||||
|
||||
// 过滤&排序
|
||||
const listeners = rendererEventListeners
|
||||
.filter(
|
||||
@ -198,7 +202,7 @@ export async function dispatchEvent(
|
||||
const checkExecuted = () => {
|
||||
executedCount++;
|
||||
if (executedCount === listeners.length) {
|
||||
unbindEvent?.();
|
||||
unbindEvent?.(eventName);
|
||||
}
|
||||
};
|
||||
for (let listener of listeners) {
|
||||
|
Loading…
Reference in New Issue
Block a user