diff --git a/packages/g6/src/plugins/contextmenu/index.ts b/packages/g6/src/plugins/contextmenu/index.ts index 8e3dee6716..6d9b1ea8cd 100644 --- a/packages/g6/src/plugins/contextmenu/index.ts +++ b/packages/g6/src/plugins/contextmenu/index.ts @@ -213,13 +213,15 @@ export class Contextmenu extends BasePlugin { }; private onMenuItemClick = (event: MouseEvent) => { - const { onClick } = this.options; + const { onClick, trigger } = this.options; if (event.target instanceof HTMLElement) { if (event.target.className.includes('g6-contextmenu-li')) { const value = event.target.getAttribute('value') as string; onClick?.(value, event.target); + this.hide(); } } - this.hide(); + + if (trigger !== 'click') this.hide(); }; }