Skip to content

Commit

Permalink
feat(context-menu): prevent event bubbling when "menus" is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
liujuping committed Jan 30, 2024
1 parent dfe6878 commit 1a68807
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/shell/src/components/context-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ContextMenu({ children, menus, pluginContext }: {
);
}

if (!menus || !menus.length) {
if (!menus) {
return (
<>{ children }</>
);
Expand All @@ -53,6 +53,9 @@ export function ContextMenu({ children, menus, pluginContext }: {
}

ContextMenu.create = (pluginContext: IPublicModelPluginContext, menus: IPublicTypeContextMenuAction[], event: MouseEvent) => {
event.preventDefault();
event.stopPropagation();

const children: React.ReactNode[] = parseContextMenuAsReactNode(parseContextMenuProperties(menus, {
pluginContext,
}), {
Expand Down

0 comments on commit 1a68807

Please sign in to comment.