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 authored and JackLian committed Jan 30, 2024
1 parent e3a1989 commit ed7befb
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 ed7befb

Please sign in to comment.