X Tutup
Skip to content

Commit 8f0291f

Browse files
liujupingJackLian
authored andcommitted
fix(context-menu): fix context menu bugs
1 parent 6ded1a6 commit 8f0291f

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

packages/designer/src/context-menu-actions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export interface IContextMenuActions {
1717
adjustMenuLayout: IPublicApiMaterial['adjustContextMenuLayout'];
1818
}
1919

20+
let destroyFn: Function | undefined;
21+
2022
export class ContextMenuActions implements IContextMenuActions {
2123
actions: IPublicTypeContextMenuAction[] = [];
2224

@@ -55,7 +57,7 @@ export class ContextMenuActions implements IContextMenuActions {
5557
const { bounds } = designer.project.simulator?.viewport || { bounds: { left: 0, top: 0 } };
5658
const { left: simulatorLeft, top: simulatorTop } = bounds;
5759

58-
let destroyFn: Function | undefined;
60+
destroyFn?.();
5961

6062
const destroy = () => {
6163
destroyFn?.();

packages/engine/src/inner-plugins/default-context-menu.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
8787
material.addContextMenuOption({
8888
name: 'copy',
8989
title: intl('Copy.1'),
90+
condition(nodes) {
91+
return nodes.length > 0;
92+
},
9093
action(nodes) {
9194
if (!nodes || nodes.length < 1) {
9295
return;
@@ -159,6 +162,9 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
159162
material.addContextMenuOption({
160163
name: 'delete',
161164
title: intl('Delete'),
165+
condition(nodes) {
166+
return nodes.length > 0;
167+
},
162168
action(nodes) {
163169
nodes.forEach((node) => {
164170
node.remove();

packages/utils/src/context-menu.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.context-menu-tree-wrap {
22
position: relative;
3-
padding: 4px 10px 4px 24px;
3+
padding: 4px 10px 4px 32px;
44
}
55

66
.context-menu-tree-children {

packages/utils/src/context-menu.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,8 @@ const Tree = (props: {
2222
const { node } = props;
2323

2424
if (!node) {
25-
return null;
26-
}
27-
28-
if (!node.parent) {
2925
return (
30-
<div className="context-menu-tree-wrap">
31-
<div className="context-menu-tree-children">
32-
{props.children}
33-
</div>
34-
</div>
26+
<div className="context-menu-tree-wrap">{ props.children }</div>
3527
);
3628
}
3729

0 commit comments

Comments
 (0)
X Tutup