fix: fix click connot trigger context menu (#6007)

This commit is contained in:
Aaron 2024-07-09 22:11:59 +08:00 committed by GitHub
parent 8180e576b4
commit d8bf0e054c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -213,13 +213,15 @@ export class Contextmenu extends BasePlugin<ContextmenuOptions> {
};
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();
};
}