GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: update comtext menu component · czfadmin/lowcode-engine@4dd6f7a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/shell/src/components
    • context-menu.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/shell/src/components/context-menu.tsx‎

Copy file name to clipboardExpand all lines: packages/shell/src/components/context-menu.tsx
+15-9Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import { createContextMenu, parseContextMenuAsReactNode, parseContextMenuProperties } from '@alilc/lowcode-utils';
22
import { engineConfig } from '@alilc/lowcode-editor-core';
33
import { IPublicModelPluginContext, IPublicTypeContextMenuAction } from '@alilc/lowcode-types';
4-
import React from 'react';
4+
import React, { useCallback } from 'react';
55

66
export function ContextMenu({ children, menus, pluginContext }: {
77
menus: IPublicTypeContextMenuAction[];
88
children: React.ReactElement[] | React.ReactElement;
99
pluginContext: IPublicModelPluginContext;
1010
}): React.ReactElement<any, string | React.JSXElementConstructor<any>> {
11-
if (!engineConfig.get('enableContextMenu')) {
12-
return (
13-
<>{ children }</>
14-
);
15-
}
16-
17-
const handleContextMenu = (event: React.MouseEvent) => {
11+
const handleContextMenu = useCallback((event: React.MouseEvent) => {
1812
event.preventDefault();
1913
event.stopPropagation();
2014

@@ -32,7 +26,19 @@ export function ContextMenu({ children, menus, pluginContext }: {
3226
}
3327

3428
destroyFn = createContextMenu(children, { event });
35-
};
29+
}, [menus]);
30+
31+
if (!engineConfig.get('enableContextMenu')) {
32+
return (
33+
<>{ children }</>
34+
);
35+
}
36+
37+
if (!menus || !menus.length) {
38+
return (
39+
<>{ children }</>
40+
);
41+
}
3642

3743
// 克隆 children 并添加 onContextMenu 事件处理器
3844
const childrenWithContextMenu = React.Children.map(children, (child) =>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.