Skip to content

Commit

Permalink
optimization right-click menu overflow unable to display
Browse files Browse the repository at this point in the history
Signed-off-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 committed Apr 7, 2024
1 parent 66c7194 commit 7e5c41b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,21 @@ const MenuList: React.FC = () => {
const handleRightClick = (info: any) => {
// 获取右键点击的节点信息
const { node, event } = info;
// 判断右键的位置是否超出屏幕 , 如果超出屏幕则设置为屏幕的最大值 往上偏移 125
if (event.clientY + 150 > window.innerHeight) {
event.clientY = window.innerHeight - 125;
}
setMenuState((prevState) => ({
...prevState,
contextMenuOpen: true,
selectedKeys: [node.key],
clickNode: { ...prevState.clickNode, rightClickedNode: node },
contextMenuPosition: {
...prevState.contextMenuPosition,
top: event.clientY + 20,
left: event.clientX + 20
top: event.clientY + 5,
left: event.clientX + 10,
screenX: event.screenX,
screenY: event.screenY,
}
}));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const Project: React.FC = (props: connect) => {
event
} = info;

// 判断右键的位置是否超出屏幕 , 如果超出屏幕则设置为屏幕的最大值 往上偏移 200px
if (event.clientY + 150 > window.innerHeight) {
event.clientY = window.innerHeight - 200;
}

// 设置右键菜单
setProjectState((prevState) => ({
...prevState,
Expand All @@ -101,7 +106,9 @@ const Project: React.FC = (props: connect) => {
contextMenuPosition: {
...prevState.contextMenuPosition,
top: event.clientY + 5,
left: event.clientX + 10
left: event.clientX + 10,
screenX: event.screenX,
screenY: event.screenY
},
selectedKeys: [key],
rightClickedNode: { ...node, ...fullInfo },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,24 @@ const ResourceOverView: React.FC = () => {
const handleRightClick = (info: any) => {
// 获取右键点击的节点信息
const { node, event } = info;


// 判断右键的位置是否超出屏幕 , 如果超出屏幕则设置为屏幕的最大值 往上偏移 150
if (event.clientY + 150 > window.innerHeight) {
event.clientY = window.innerHeight - 75;
}

setResourceState((prevState) => ({
...prevState,
selectedKeys: [node.key],
rightClickedNode: node,
contextMenuOpen: true,
contextMenuPosition: {
...prevState.contextMenuPosition,
left: event.clientX + 20,
top: event.clientY + 20
top: event.clientY + 5,
left: event.clientX + 10,
screenX: event.screenX,
screenY: event.screenY
}
}));
};
Expand Down

0 comments on commit 7e5c41b

Please sign in to comment.